6. log it


/*jshint multistr:true */

var text =  "Kaj likes coding\
but has some problems with this code. can you help him?";

var myName = "Kaj";
var hits = []

for(var i = 0; i<text.length; i++){
    if(text[i] === "K"){
           for(var j = i; j<i+myName.length; j++){
if (hits.length === 0){
    console.log("Your name wasn't found!");
    else {

what is wrong with this code?


Is there some behaviour that you want to change? If so, what is it that you want it to do differently?


wel jonatan. all i want to know is. what's wrong with this code because. every time i click on Save & Submit. there comes an error message saying that there's an SyntaxError: Parser error. but i don't know what to do. so can you please help me


Sure. But "help" or "what's wrong" doesn't explain what's going on. Put yourself in the shoes of those that are going to read your post, make sure there's a reasonable way to respond.

Some guy walks up to you and asks you what is wrong with their lollipop. What do you tell them? There's not enough information!

Having a syntax error and wanting to find it on the other hand, that describes a problem.

If you indent your code by your curly braces (you should keep your code well formatted the whole time while working on it) - then you'll find that you are closing more blocks than you have opened, that is, you have more }'s than you have {'s

For example, this is not valid javascript:
(just this one line as the whole code)


Because there is no block to close


thank you for the tips. i will use them the next time


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