Hi there, I am working on a website at the moment and I am using the firefox console quite a lot.
I am in the process of testing a script and I have noticed something really odd, hopefully somebody might be able to tell me whether there is something I am doing wrong.
Take the following code:

console.log("Height is " + height + " New position value is " + newPositionValue + " hey ");

The output is all ok. Because some of the output are quite long, for legibility in the text editor I am using, I started to split the arguments of the console.log like this:

console.log("Height is " + height + " New position value is " + 
+ newPositionValue + " hey ");

and so on. The thing is if I split the code like the above the results are ok but if I split it like this instead

console.log("Height is " + height + " New position value is " + newPositionValue + 
 + " hey ");

the last string returns NaN. In other words if the string is on the other line on its own like + " hey "); it returns NaN but if I have the variable plus the string like + newPositionValue + " hey "); it is ok. Has anybody ever heard of this?
thanks

That's exactly what it sohuld return.
You are trying to convert the string " hey " into a Number.
Actually NaN is the result of the given conversion.

var height = 55,newPositionValue = 12; 
console.log("Height is " + height + " New position value is " + newPositionValue + 
 + " hey ");

result *>> LOG: Height is 55 New position value is 12NaN *

The same will happen on IE dev also.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.