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).