Created
May 7, 2020 10:09
-
-
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=
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 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