Skip to content

Instantly share code, notes, and snippets.

@pradeeprjth
Created August 18, 2021 06:44
Show Gist options
  • Save pradeeprjth/f2ed94f1e85c1b235f96b51427b0ae46 to your computer and use it in GitHub Desktop.
Save pradeeprjth/f2ed94f1e85c1b235f96b51427b0ae46 to your computer and use it in GitHub Desktop.
console.clear()
var mList = [1, 2, 3, 4, 5]
// var pos;
// for(pos = 0; pos < mList.length; pos++) {
// console.log('Position => ' + pos + ' Value => ' + mList[pos])
// }
// Break Keyword
// var pos;
// for(pos = 0; pos < mList.length; pos++) {
// if(pos >= 3) break
// console.log('Position => ' + pos + ' Value => ' + mList[pos])
// }
// Continue Keyword
var pos;
for(pos = 0; pos < mList.length; pos++) {
if(pos % 2 === 0) continue
console.log('Position => ' + pos + ' Value => ' + mList[pos])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment