Last active
January 18, 2021 04:33
-
-
Save sumanssaurabh/416eeaa879eafd16a0da6349b22b8865 to your computer and use it in GitHub Desktop.
iterate loop without for loop
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
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
let counter = 0; | |
const len = arr.length; | |
const iterate = () => { | |
if (counter < len) { | |
console.log(arr[counter]); | |
counter = counter + 1; | |
iterate(); | |
} | |
}; | |
//invoke | |
iterate(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment