6.Log it


This is my code.
var text="jsdncjdsncjnjdnmc dncj Dunja hsdhsghhvdgv Dunja hsdghegde Dunja";
var myName="Dunja";
var hits=[];
for (var i=0;i if(text[i]===myName[0]) {
for (var j=i;j hits.push(text[j]);}
if (hits.length=0) {
console.log("Your name was not found.");
else {
I get way to go! from computer, but it is not right. Code displays only: "[]".
Why is that and where is the mistake?


Isn't it

hits.length === 0?

Except you put

Just a confusion.:smiley:


examples: var myName = Someones Name; // 'Someones Name' is 13 characters, that's counting the space also.

// copy an paste this above from the example, ( You can change it back to your name later //

if (hits.length=0) { // //hits.length should be === "Someones Name

console.log("Your name was not found."); { // Use 'Someones Name' in console.log

// Will printout 'Someones Name'

} else {
console.log(hits); // copy an paste all of the above text, ( You can change to your name later)

} // This example will work for sure ( you can make changes later //