'F' → Fullscreen
parseInt() parseFloat() console.log("--- Demo 1 - Age to Months Calculator ---");
// Convert input to a number in two steps (simple, but tedious).let input = prompt("Enter your age:"); // 1) User types in agelet age = parseInt(input); // 2) Convert string input to an integerconsole.log(`You are ${age} years old. That's ${age * 12} months old!`);
alert("\nPress enter to continue...");//console.log("--- Demo 1 - Age to Months Calculator ---");
// Convert input to a number in two steps (simple, but tedious).let input = prompt("Enter your age:"); // 1) User types in agelet age = parseInt(input); // 2) Convert string input to an integerconsole.log(`You are ${age} years old. That's ${age * 12} months old!`);
alert("\nPress enter to continue...");
// -----------------------------------------------------------------------------
console.log("--- Demo 2 - Square Area Calculator ---");
// Convert input to a number in one steplet length = parseFloat(prompt("Enter the length of the square: "));let area = length * length;console.log(`The area of the square is ${area}`);
alert("\nPress enter to continue...");//console.log("--- Demo 1 - Age to Months Calculator ---");
// Convert input to a number in two steps (simple, but tedious).let input = prompt("Enter your age:"); // 1) User types in agelet age = parseInt(input); // 2) Convert string input to an integerconsole.log(`You are ${age} years old. That's ${age * 12} months old!`);
alert("\nPress enter to continue...");
// -----------------------------------------------------------------------------
console.log("--- Demo 2 - Square Area Calculator ---");
// Convert input to a number in one steplet length = parseFloat(prompt("Enter the length of the square: "));let area = length * length;console.log(`The area of the square is ${area}`);
alert("\nPress enter to continue...");
// -----------------------------------------------------------------------------
console.log("--- Demo 3 - Score Calculator ---");
let score1 = parseFloat(prompt("Enter the score for game 1: "));let score2 = parseFloat(prompt("Enter the score for game 2: "));let score3 = parseFloat(prompt("Enter the score for game 3: "));let totalScore = score1 + score2 + score3;console.log(`Your total score for the three games is ${totalScore}!`);
alert("\nPress enter to continue...");//console.log("--- Demo 1 - Age to Months Calculator ---");
// Convert input to a number in two steps (simple, but tedious).let input = prompt("Enter your age:"); // 1) User types in agelet age = parseInt(input); // 2) Convert string input to an integerconsole.log(`You are ${age} years old. That's ${age * 12} months old!`);
alert("\nPress enter to continue...");
// -----------------------------------------------------------------------------
console.log("--- Demo 2 - Square Area Calculator ---");
// Convert input to a number in one steplet length = parseFloat(prompt("Enter the length of the square: "));let area = length * length;console.log(`The area of the square is ${area}`);
alert("\nPress enter to continue...");
// -----------------------------------------------------------------------------
console.log("--- Demo 3 - Score Calculator ---");
let score1 = parseFloat(prompt("Enter the score for game 1: "));let score2 = parseFloat(prompt("Enter the score for game 2: "));let score3 = parseFloat(prompt("Enter the score for game 3: "));let totalScore = score1 + score2 + score3;console.log(`Your total score for the three games is ${totalScore}!`);
alert("\nPress enter to continue...");
// -----------------------------------------------------------------------------
console.log("--- Demo 4 - Shopping Cart Subtotal ---");
let item1Price = parseFloat(prompt("Enter the price of the first item: "));let item2Price = parseFloat(prompt("Enter the price of the second item: "));let subtotal = item1Price + item2Price;
// There is a function for making the dollar amount go to two decimals.// Try subtotal.toFixed(2) inside the string template.console.log(`The subtotal for your two items is $${subtotal}.`);
alert("\nPress enter to continue...");//console.log("--- Demo 1 - Age to Months Calculator ---");
// Convert input to a number in two steps (simple, but tedious).let input = prompt("Enter your age:"); // 1) User types in agelet age = parseInt(input); // 2) Convert string input to an integerconsole.log(`You are ${age} years old. That's ${age * 12} months old!`);
alert("\nPress enter to continue...");
// -----------------------------------------------------------------------------
console.log("--- Demo 2 - Square Area Calculator ---");
// Convert input to a number in one steplet length = parseFloat(prompt("Enter the length of the square: "));let area = length * length;console.log(`The area of the square is ${area}`);
alert("\nPress enter to continue...");
// -----------------------------------------------------------------------------
console.log("--- Demo 3 - Score Calculator ---");
let score1 = parseFloat(prompt("Enter the score for game 1: "));let score2 = parseFloat(prompt("Enter the score for game 2: "));let score3 = parseFloat(prompt("Enter the score for game 3: "));let totalScore = score1 + score2 + score3;console.log(`Your total score for the three games is ${totalScore}!`);
alert("\nPress enter to continue...");
// -----------------------------------------------------------------------------
console.log("--- Demo 4 - Shopping Cart Subtotal ---");
let item1Price = parseFloat(prompt("Enter the price of the first item: "));let item2Price = parseFloat(prompt("Enter the price of the second item: "));let subtotal = item1Price + item2Price;
// There is a function for making the dollar amount go to two decimals.// Try subtotal.toFixed(2) inside the string template.console.log(`The subtotal for your two items is $${subtotal}.`);
alert("\nPress enter to continue...");
// -----------------------------------------------------------------------------
console.log("--- Demo 5 - Hours to Minutes Converter ---");
let hours = parseFloat(prompt("Enter a number of hours: "));let minutes = hours * 60;console.log(`${hours} hours is equal to ${minutes} minutes.\n`);//Your program output should something similar to the sample output below.
--- Demo 1 - Age to Months Calculator ---Enter your age: 35You are 35 years old. That's 420 months old!
Press enter to continue... [Enter]--- Demo 2 - Square Area Calculator ---Enter the length of the square: 11.5The area of the square is 132.25
Press enter to continue... [Enter]--- Demo 3 - Score Calculator ---Enter the score for game 1: 45Enter the score for game 2: 64Enter the score for game 3: 99Your total score for the three games is 208!
Press enter to continue... [Enter]--- Demo 4 - Shopping Cart Subtotal ---Enter the price of the first item: 12.50Enter the price of the second item: 10The subtotal for your two items is $22.5.
Press enter to continue... [Enter]--- Demo 5 - Hours to Minutes Converter ---Enter a number of hours: 1212 hours is equal to 720 minutes.You may write your reflection answers as comments at the bottom of your code.
parseInt() function versus the parseFloat() function? Give one specific example for each.
Submit your activity and reflection answers to the appropriate dropbox.