Skip to content

Instantly share code, notes, and snippets.

@adedayojs
Last active January 16, 2020 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adedayojs/2650892cfdbb29de83c7379b9c8133a4 to your computer and use it in GitHub Desktop.
Save adedayojs/2650892cfdbb29de83c7379b9c8133a4 to your computer and use it in GitHub Desktop.
// This function allows you to loop through a certain number of times
// It is similar to the range function in python (if you are familiar with python)
function loopNumbers(number){
for(let i of [].constructor(number)){
// Do your thing
}
// Other function related things
}
// You could Just extract the for loop like this
// Mind You Replace number with the number you intend
for(let i of [].constructor(number)){
// Do your thing
}
/*** EXAMPLE ****/
for(let i of [].constructor(7)){
// Do your thing
console.log('Called')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment