Dec 19, 2023
Tutorials
ZxStim
for
, while
, and do while
loops.while
and do while
loops are rarely used.Compile and deploy the code block below:
solidityLoop.sol// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; contract Loop { function loop() public { // for loop for (uint i = 0; i < 10; i++) { if (i == 3) { // Skip to next iteration with continue continue; } if (i == 5) { // Exit loop with break break; } } // while loop uint j; while (j < 10) { j++; } } }