INFO 253A: Front End Web Architecture
Kay Ashaolu
function getGenerationalCohort(yearBorn) {
let generationalCohort = ""
if (yearBorn > 1900 && yearBorn <= 1926) {
generationCohort = "GI Generation";
}
else if (yearBorn > 1926 && yearBorn <= 1945) {
generationalCohort = "Silent Generation";
}
else if (yearBorn > 1945 && yearBorn <= 1964) {
generationalCohort = "Baby Boomers";
}
else if(yearBorn > 1964 && yearBorn <= 1980) {
generationalCohort = "Generation X";
}
else if(yearBorn > 1980 && yearBorn <= 2001) {
generationalCohort = "Millennium";
}
else if(yearBorn > 2001 && yearBorn < 2020) {
generationalCohort = "Generation Z";
}
else {
generationalCohort = "Outside of our named generations";
}
return generationalCohort;
}
let year = parseInt(prompt("Enter your year of birth"));
let cohort = getGenerationalCohort(year);
alert("The generational cohort of someone born in " +
year + " is: " + cohort + ".");
function countToX(x) {
let message = "";
for(let i = 0; i <= x; i = i+1) {
message = message + i + " ";
}
return message;
}
let limit = parseInt(prompt("Enter a number"));
let output = countToX(limit);
alert(output);
let answerQuestion = function() {
let answer = prompt("What is 4 + 4");
if (answer == "8") {
return true;
}
else {
return false;
}
}
let answer = false;
while (answer != true) {
answer = answerQuestion();
}
alert("Correct Answer!");
let student = {
name: "Kay Ashaolu",
id: 232324,
lab_grades: [1, 1, 1],
assignment_grades: [87, 98, 82]
};
alert(student);
alert(student.name);
alert(student["lab_grades"]);
alert(student.assignment_grades[2]);
let student = {};
student.name = prompt("Enter your name");
student.attempts = [];
let answer = false
while(answer != true) {
value = prompt("What is 8+8?");
student.attempts.push(value);
if(value == "16") {
answer = true;
}
else {
answer = false;
}
}
alert(student.name + " answers: " + student.attempts);