Last active
August 29, 2020 07:46
-
-
Save gwmccubbin/2bea3fe75b62c17b5bbb8d4f3f512f06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
contract MyContract { | |
uint[] public numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
address public owner; | |
constructor() public { | |
owner = msg.sender; | |
} | |
function countEvenNumbers() public view returns (uint) { | |
uint count = 0; | |
for(uint i = 0; i < numbers.length; i++) { | |
if(isEvenNumber(numbers[i])) { | |
count ++; | |
} | |
} | |
return count; | |
} | |
function isEvenNumber(uint _number) public view returns(bool) { | |
if(_number % 2 == 0) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function isOwner() public view returns(bool) { | |
return(msg.sender == owner); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment