Request a user’s name and display the response “Hello, [name]”
let name = prompt ("enter name");
alert("hello" + " " + name);
alert('hello ${name}')
Request a user’s year of birth, count his age, and display the result. Store the current year as a constant
let ageInput = prompt ("enter birth year");
const YEAR = 2022
alert (YEAR - parseFloat(ageInput) -1)
Request a length of a side of a square from a user and display the perimeter of the square
let squereSide = prompt ("enter squere side length");
alert(squereSide * 4)
Request a radius of a circle and display the area of such a circle
const PI = 3.14159;
let radius = prompt("circle radius");
alert(PI * (radius*2))
Request a distance in km between the two cities from a user, and the time they want to cover it within. Count the speed needed to be on time
let distanceCovered = prompt("distance? (km)");
let timeBetween = prompt("time? (hrs)");
alert (distanceCovered/timeBetween)
Create a currency converter. A user types in USD and the program converts them to EUR. The exchange rate should be stored as a constant
const RATE = 0.9;
let USD = prompt("USD exchange into EUR");
alert(USD * 0.9)
The user types in a sum of bank deposits for 2 months with a yearly interest rate of 5%. The program counts the sum of interest
const RATE = 0.05;
let sum = prompt("input sum of your bank deposits");
alert(sum * RATE / 6)
Top comments (1)
Thanks 🙏