Privacy preferences

Choose separately whether we may use analytics and advertising measurement. Both stay off unless you turn them on. You can change these choices any time.

All challenges

Challenge 2

Solidity function bug

LowSolidity basics

Challenge

Can you solve this Solidity function bug? Check whether the declared return type matches the returned value.

Starter code

// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;

contract Storage {
  string s_name;

  function changeName(string memory _name) public {
    s_name = _name;
  }

  function getName() public view returns (bool) {
    return s_name;
  }
}
Show hint

A function's return type must match the value it returns.