Skip to content

Instantly share code, notes, and snippets.

@edinsoncs
Created May 23, 2016 00:14
Show Gist options
  • Select an option

  • Save edinsoncs/b801f64c16a40055dc61d2a1c6178c84 to your computer and use it in GitHub Desktop.

Select an option

Save edinsoncs/b801f64c16a40055dc61d2a1c6178c84 to your computer and use it in GitHub Desktop.
var arr = ['edinson', 'richard', 'luis', 'ashly'];
function modeQuestion() {
var question = prompt('Iteration Mode');
return question
}
function iteration(mode){
if(mode == 'for'){
for(var i = 0; i < arr.length; i++) {
console.log('Names register in arrays: ' + arr[i]);
}
}
else if(mode == 'foreach') {
arr.forEach(function(index, secondary, tree ,complete){
console.log('Names register in arrays: ' + index);
});
}
else if(mode == 'map') {
arr.map(function(index, secondary, tree, complete){
console.log('Names register in arrays: ' + index);
});
}
}
iteration(modeQuestion());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment