3

I have a Javascript For Loop...

var CookieName = "Tab,EduTab,EduTab,user";
var tString = CookieName.split(',');

for(i = 0; i < tString.length; i++){

    if (tString[i] == "EduTab") {
        document.write("<b>"+tString[i]+"<b>"); 
    } else {
        document.write(tString[i]);
    }
}

For some reason it is failing to bold the 'EduTab'. It will either bold the entire array CookieName or none at all. Any help would be awesome. Thanks.

2 Answers 2

7

You aren't closing the <b> tag

document.write("<b>"+tString[i]+"<b>")

should be

document.write("<b>"+tString[i]+"</b>")
Sign up to request clarification or add additional context in comments.

Comments

7

You are missing the / in your closing tab </b>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.