Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to return the stored value from the function.
Blockchain / Solidity
function getValue() public view returns (uint) {
return [1];
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Returning the function name instead of the variable.
Returning the type instead of the variable.
Using the keyword 'return' twice.
✗ Incorrect
The function returns the variable value which holds the stored number.
2fill in blank
mediumComplete the code to return the sum of two numbers.
Blockchain / Solidity
function add(uint a, uint b) public pure returns (uint) {
return a [1] b;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction instead of addition.
Using multiplication or division operators by mistake.
✗ Incorrect
The function returns the sum of a and b using the plus operator +.
3fill in blank
hardFix the error in the return statement to correctly return the balance.
Blockchain / Solidity
function getBalance() public view returns (uint) {
uint balance = 100;
return [1];
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Returning a variable name that does not exist.
Adding parentheses to a variable name.
Returning the function name instead of the variable.
✗ Incorrect
The variable balance holds the value to return. Using balance() or other names causes errors.
4fill in blank
hardFill both blanks to return the product of two numbers plus 1.
Blockchain / Solidity
function multiply(uint x, uint y) public pure returns (uint) {
return x [1] y [2] 1;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of multiplication first.
Using subtraction or division operators.
✗ Incorrect
The function multiplies x and y using * and then adds 1 with +.
5fill in blank
hardFill both blanks to return a formatted string with the user's name and age.
Blockchain / Solidity
function getUserInfo(string memory name, uint age) public pure returns (string memory) {
return string(abi.encodePacked([1], ": ", [2], " years old"));
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to concatenate a number without converting it to string.
Using the wrong function to convert number to string.
Missing the variable name for the first blank.
✗ Incorrect
The function returns a string combining the name and the age converted to string using toString(age).