FUNDAMENTALS OF COMPUTER

COMPUTER PROGRAMMING FUNDAMENTALS

WHAT IS PROGRAMMING

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
var lives = 3;
A
adds the value of 3 to the sprite lives
B
assigns 3 to the variable score
C
declares a variable named lives and then initializes the value of lives to 3
D
None of the above
Explanation: 

Detailed explanation-1: -When you declare a variable, you should also initialize it. Two types of variable initialization exist: explicit and implicit. Variables are explicitly initialized if they are assigned a value in the declaration statement. Implicit initialization occurs when variables are assigned a value during processing.

Detailed explanation-2: -Variables declared using var are created before any code is executed in a process known as hoisting. Their initial value is undefined .

Detailed explanation-3: -Initializing a variable means specifying an initial value to assign to it (i.e., before it is used at all). Notice that a variable that is not initialized does not have a defined value, hence it cannot be used until it is assigned such a value.

There is 1 question to complete.