Created
March 20, 2016 01:50
-
-
Save willianrschuck/75b7a2dc7f4e46206ba9 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
| // Exercise of the course "JavaScript - Codecademy (https://www.codecademy.com)" | |
| // Student - Willian Schuck | |
| // Creates the variables | |
| var text = "Willian, are now programming. Please, talk with Wilbor"; | |
| var myName = "Willian"; | |
| var hits = []; | |
| // Exercise requirements.. I will not comment them.. ;P | |
| for (var c = 0; c < text.length; c++) { | |
| if (text[c] === myName[0]) { | |
| // Reset the previus value.. or defines the variable; | |
| var fName = "" | |
| for (var d = c; d < c + myName.length; d++) { | |
| var fName = fName + text[d]; | |
| if (fName === myName) { | |
| hits.push(fName); | |
| }; | |
| }; | |
| // Returns to line 10, if the sentence returns true, it reloads the code of lines 13 - 20; | |
| }; | |
| }; | |
| if (hits.length == 0){ | |
| console.log("Seu nome nao foi encontrado!"); | |
| }else{ | |
| console.log(hits); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment