Mark Girling

Learn modern, professional web development with HTML, CSS, JavaScript, React, and Node.js.

Homepage JavaScript Challenges

JavaScript Challenge 2

Challenge

What does the console.log print in this code snippet?

const obj1 = {
  foo: 'bar',
};

const obj2 = {
  foo: 'baz'
};

const obj3 = {};
obj3[obj1] = 'foo';
obj3[obj2] = 'bar';

console.log(obj3[obj1]);

Answer

'bar'

This is because when you set an object property, whatever you specify as the key …

Read more...

JavaScript Challenge 1

If you're learning JavaScript, here's something to help you. I'm going to be posting a little JavaScript challenge every day for you to solve.

The idea is that the challenges will cover many different language features. Some will be shorter/longer than others.

Feel free to use documentation/tutorials such as MDN to help you.

Read more...