Last active
August 29, 2015 14:03
-
-
Save rmariuzzo/0d351d2aa88c13c39dbe to your computer and use it in GitHub Desktop.
Revisions
-
rmariuzzo revised this gist
Jul 14, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // Proposed solution for an exercise given to a friend: http://pastebin.com/hjFCZYE7 function printList(linePrefix, list) { for (var i = 0; i < list.length; i++) { -
rmariuzzo created this gist
Jul 14, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ // Solution proposed for: http://pastebin.com/hjFCZYE7 function printList(linePrefix, list) { for (var i = 0; i < list.length; i++) { if (typeof list[i] === 'string') { console.log(linePrefix + '.' + i + ': ' + list[i]); } else { printList(linePrefix + '.' + i, list[i]); } } } var sample = ["Red",["Yellow","Green","Blue"],"Black",[["Orange","Purple"],"White"]]; printList('Test', sample);