Created
May 23, 2016 00:14
-
-
Save edinsoncs/b801f64c16a40055dc61d2a1c6178c84 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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