Table of Contents
Back Button
Back to Chapter
Control Statements
No items found.
Function & Events
No items found.
Array and its Types
No items found.
OOP : Object Oriented Programming
No items found.
Javascript Standards
No items found.
HTML DOM
No items found.
Javascript : Advanced 1
No items found.
Javascript : Advanced 2
No items found.
Additional JavaScript
No items found.

Basic Syntax & Declaration Exercise

Question

Make a Program That Input the Name, Address, Year of Birth (DOB) and Output the Data After Calculating the Age of Person in the Following Manner

"Hello!!! I am {Person Name}, I am {Age} Years Old and Lives in {Address}.

**Example: "**Hello!!! I am John Doe, I am 25 Years Old and Live in B-25 Ramshri Society New Delhi (India). "

Note : You have to Assign Dummy Values to Variables and Generate Output.

Hint

Use var to input Name and Address and Year of Birth.

Now Take a New var and Calculate (Current Year - Year of Birth).

Print The Data in Console Tab.

Solution

var name = "John Doe";
var address = "B-25 Ramshri Society New Delhi (India)";
var dob = 2002;

var age = 2021 - 2002;

console.log("Hello!!! I am " + name + ". I am " + age + " Years Old and live in " + address + ".");

// Output
// Hello!!! I am John Doe, I am 25 Years Old and Live in B-25 Ramshri Society New Delhi (India).

Ask queries
Contact Us on Whatsapp
Hi, How Can We Help You?