Hello I'm new to coding and I wanted to try how far I've learned ( not so much ) So I made this:
var Name = prompt('What is your name?')
var Name
var Age = prompt('What is your age?')
var Age
const RealAge = 2018 - Age
if (Name && RealAge) {
console.log("Hello " + Name + " you were born in " + RealAge + ' ...')
} else if (typeof Name == 'undefined') {
console.log("Please insert your name")
} else if (typeof Age == 'undefined' ) {
console.log("Please insert your age")
}
I want to know how to make the console.log says "Please insert your name" if you leave the first prompt empty and "Please insert your age" if the second prompt was left empty.
I'm sorry if this is a stupid question but I just started 2 days ago and I'll appreciate your help :)
if (Name === '')andif(Age === '')should do the trick. Also, you should check that before trying to computerRealAge