Skip to content

Instantly share code, notes, and snippets.

@andrejrakic
Created May 7, 2020 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrejrakic/9f6c8e70da7df36c2b28d2eb1625a1fc to your computer and use it in GitHub Desktop.
Save andrejrakic/9f6c8e70da7df36c2b28d2eb1625a1fc to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.6+commit.6c089d02.js&optimize=false&gist=
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 pure returns(bool) {
if (_number % 2 == 0) {
return true;
} else {
return false;
}
// Ili samo
// return (_number % 2 == 0);
}
function isOwner() public view returns(bool) {
return (msg.sender == owner);
// if (msg.sender == owner) {
// return true;
// } else {
// return false;
// }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment