JSFiddle - React, Tailwind, and code Playground
by jairajdesai
JavaScript
var addperson = prompt("Would you like to add someone yes or no?( you must type 'yes' in this exact way)");
if (addperson == "yes") {
var firstName = prompt("What is this person's first name?");
var lastName = prompt("What is this person's last name?");
var age = prompt("How old is this person?");
var email = prompt("What is their email adress?");
if (!/^[@]+$/.test(email) || !email) {
alert("Your email is valid");
} else {
alert("You did not give a valid email please re-type it, and make sure you include the @ symbol");
}
newPeople(firstName, lastName, age, email);
}
function newPeople(firstName, lastName, age, email) {
var something = [];
something.push({
"FirstName": firstName,
"LastName": lastName,
"Age": age,
"Email": email
});
console.log(something);
}