codebar / tutorials

🗒 codebar's tutorials
http://tutorials.codebar.io/
258 stars 243 forks source link

(JS lesson 2) Rename population var #459

Closed chrislawes closed 4 years ago

chrislawes commented 4 years ago

Hey,

I was helping someone with this lesson, and they found it confusing when creating the displayPopulation function, as the first variable was named the same as the object key they needed to reference.

var london = {
  name: 'London',
  population: 8308369,
  // ...
}
function displayPopulation() {
  var population = document.createElement('p');
  // ...
}

I've changed the variable name from "population", to "paragraph".

This helps the next line read nicer too; "append content to paragraph", rather than "append content to population"

paragraph.appendChild(content);