Created
September 24, 2015 02:53
-
-
Save dnasca/fb26dc02a9d30ae8f9af to your computer and use it in GitHub Desktop.
finding and pushing a string to an array
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 text = "This string contains the name Derrik"; | |
| var myName = "Derrik"; | |
| var hits = []; | |
| for(var i = 0; i < text.length; i++) { | |
| if (text[i] === 'D') { | |
| for(var j = i; i > (myName.length + i); j++) { | |
| hits.push(text[j]); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment