Algorithm


Problem Type - 

Data Types Example - Assign & Print

 

Problem Details:

Assign your Age variable to a number called age and print it in browser console.

 

All possible data types in JavaScript - 

var age = 26;                           // number 
var name = "Jhon";                      // string
var name = {first:"Jhon", last:"Doe"};  // object
var truth = false;                      // boolean
var sheets = ["HTML","CSS","JS"];       // array
var a; typeof a;                        // undefined
var a = null;                           // value null

Read Reference About all data types of JavaScript (If any lackings)

Code Examples

#1 Assign age to a variable and print

Code - Javascript Programming


var age = 26;
console.log("Your Age = " + age);
Copy The Code & Try With Live Editor

Output

x
+
cmd
Your Age = 26

#2 Assign name to a variable and print

Code - Javascript Programming


var name = "Akash";
console.log("Your Name = " + name);
Copy The Code & Try With Live Editor

Output

x
+
cmd
Your Name = Akash
Advertisements

Demonstration


Various data types in Javascript - 

var age = 26;                           // number 
var name = "Jhon";                      // string
var name = {first:"Jhon", last:"Doe"};  // object
var truth = false;                      // boolean
var sheets = ["HTML","CSS","JS"];       // array
var a; typeof a;                        // undefined
var a = null;                           // value null
Previous
JavaScript Practice Example #1 - Print Hello World in JavaScript in Browser Console
Next
JavaScript Practice Example #3 - Assign 3 Variables and Print Good Way