Second For loop not working keeping getting error


not reading the text and also receiving syntax error

var text = "Im the best DJ in the world.";
var myName = "Coby";
var hits = [];
for (i = 0; i < text.length; i++) {
    if (text[i] === "C") {
        for(var j = i; j < (i + myName.length; j++)


You're missing a parenthesis here: for(var j = i; j < (i + myName.length; j++)


i corrected the parenthesis but now receiving the error " unexpected token"


Nothing in your text string contains "Coby". Your 2nd for loop won't run until "C" appears in the text string.


That's also true, but he's still getting a syntax error.

@djhollywoodcole Could you post the updated code?


[quote="djhollywoodcole, post:1, topic:46367"]

Just add '.push' to hits


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.