Javascript Practice 01: JS Hero - Variables


Question: 

Declare a variable firstname and initialize it with the value 'Lata'.





Answer: 

This is a fairly simple exercise. 
> Can declare variables in 3 ways. 
> var, let & const

var firstname = 'Lata'; or (pre - ES6 Variable) (function scoped)
let firstname = 'Lata'; or (ES6 Variables) (block scoped)
const firstname = 'Lata'; (ES6 Variables) (block scoped)

All the 3 options will work. 
They have different properties.  
You can refer to MDN Webdocs or W3Schools for further information. 

Comments

Popular posts from this blog

Junior Developer Central JS Practice Exercise - 22

Junior Developer Central JS Practice Exercise - 21

Javascript Practice 68: JS Hero - do...while loop