Skip to content

Instantly share code, notes, and snippets.

@gwmccubbin
Last active August 29, 2020 07:46
Show Gist options
  • Save gwmccubbin/2bea3fe75b62c17b5bbb8d4f3f512f06 to your computer and use it in GitHub Desktop.
Save gwmccubbin/2bea3fe75b62c17b5bbb8d4f3f512f06 to your computer and use it in GitHub Desktop.
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