Answer: A variable is a container for a value, which can be of various types.
Answer: A constant is a container for a value, which can be of various types, but once set, it cannot be changed.
let userAge = 30;
Answer: The variable is userAge and the data of the variable is 30.
let age = 30;
alert(age);
with this one
alert(30);
Answer: Yes. age is a variable that stores 30 as a value. Whenever you refer to the variable, you could also directly use the value (without storing it in a variable) first.
let age = 30;
alert(age);
can be re-written as ?
alert(30);
Answer: Variables are used to store values that can be used later in the code. They are used to store values that can be used multiple times in the code. They are also used to store values that can be changed later in the code. They are used to store values that are calculated based on other values
Answer: The = operator is an assignment operator.
Answer: Data you work with in your code is of different type -e.g. numbers,text etc...
Question 2 : Which of the followwing statements correctly creates a number and stores it in a constant ?
const userAge = '30';
const userAge = let 30;
const userAge = 30;
Answer: This is correct :
const userAge = 30;
Answer: No.
let myOtherName;
const myName = 'Max';
myName='Max';
alert(myName);
let myOtherName;
const myName = 'Max';
myOtherName='Max';
alert(myName);
let myOtherName;
const myName = 'Max';
myName=30;
alert(myName);
Answer: This is correct :
let myOtherName;
const myName = 'Max';
myOtherName='Max';
alert(myName);
Question 5 : Givent that JavaScript is a weakly typed, dynamic language, would you expect that this code works ?
let myName = 'Max';
myName = 30;
Answer: This code snippet will work. Variables in JavaScript are NOT tied to data types.