Object Logs final key to console without using console.log


#1

When I create an object and run it it ends up outputting the final key in the object without me trying to make it do that.
Is this normal?
I can’t seem to find something wrong or missing.

when I enter this

var myObject = {};
myObject.key1 = "This doesn't log",
myObject.key2 = "But this does";

It prints out this

"But this does" 

#2

console behaviour, the last value is echoed.

But that was the old learning environment, i thought it didn’t occur on the new one, can you share the exercise url?


#3

So just fiddling around I tried using literal notation and for some reason it stopped doing it.
There must be something I’m missing in the original sample.

Doing it like this

var myObject = {
key1:"This doesn't log",
key2:"But this does"
};

Doesn’t print anything.


#4

https://www.codecademy.com/en/courses/javascript-beginner-en-3bmfN/0/6?curriculum_id=506324b3a7dffd00020bf661


#5

thanks for the prompt reply


#6

its console behaviour, i wouldn’t worry about it just yet

i would highly recommend upgrading the a supported course:

https://www.codecademy.com/learn/learn-javascript

or if you prefer es6:

https://www.codecademy.com/learn/introduction-to-javascript

the course you are currently taking is no longer supported


#7

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