Cryptocurrency Ethereum Mastering Development

ParserError pragma solidity ^0.4.21

thank you so much for your help
I really appreciated
this contract give me error in the line with (length)
“ParserError: Expected primary expression.
returns candidate.length”

pragma solidity ^0.4.21;

contract Election {

    struct Candidate {
        string name;
        uint voteCount;

    struct Voter {
    bool authorized;
    bool voted;
    uint vote;
    address public owner;
    string public electionName;

    mapping(address => Voter) public voters;
    Candidate[] public candidates;
    uint public totalVotes;

    modifier ownerOnly() {
        require(msg.sender == owner);

    function Election(string _name) public {
        owner = msg.sender;
        electionName = _name;

    function addCandidate(string _name) ownerOnly public {

    function getNumCandidate() public view returns(uint){
        returns candidates.length;

    function authorize(address _person) ownerOnly public{
        voters[_person].authorized = true;

    function vote(uint _voteIndex) public {

        voters[msg.sender].vote = _voteIndex;
        voters[msg.sender].voted = true;

        candidates[_voteIndex].voteCount +=1;
        totalVotes +=1;

    function end() ownerOnly public {

Leave a Reply

Your email address will not be published. Required fields are marked *