6. log it


#1

Hi brothers:

I think is finished, it prints on the screen the names...but codecademy still show me the an error:"did you remember log the result blah bla blah......."

Here is my code:

/*jshint multistr:true */

var text = "balaabl blabjalb lbja laj Maikel jasj \
Maikel ajbo lkasj oke o kik Maikel."

var myName = "Maikel"
var hits = []

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


#2

a bug in your code. Here you do it right:

console.log("Your name wasn't found");

but then for some reason 3 lines below you add a equal sign after console:

console.log=(hits);

remove the equal sign. console.log is a function, you don't want it to be a variable holding a value


#3

@almusan,

Have a close look at

console.log=(hits);

and reset your Browser

++++ reset of session *****************
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser

and

Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

Addendum
General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).
CTRL 0 to reset browser zoom


#4

thanks a lot !!! it helps me