Overview
The purpose of today’s lab is to create a JavaScript to practice taking input from the user and returning output to the user. This lab will also allow you to practice using functions and if statements to accomplish small programming tasks.Lab work
1. Download A2.zip and extract the html file it contains. Have a look at the HTML file and notice the buttons and divs that have been created for you. Do not modify the HTML code. How to extract files: https://www.wikihow.com/Unzip-a-File
2. In Sublime/Atom/Notepad++ create a new file and save it as a2.js. Make sure that this file is in the same directory as a2.html.
3. In a2.js, write the JavaScript to complete the following exercises.
a) Write a function called convertWeight() that prompts the user to enter their weight in pounds and then displays that weight in kilograms in div1 on webpage. One pound is 0.454 kilograms.
b) Write a function called calculatePay() that prompts the user to enter how many hours they worked. The function should then display how much money the user makes if they are paid $12/hr for the first 40 hours worked, and $18/hr for every hour after that. Display the total pay in div2 on the webpage.
c) Write a function called makeUsername() that prompts the user to enter three separate pieces of information to store in variables: the first name, the last name, and the 4 digit birth year.The function should then print a username to div3 the webpage. The usernameshould contain the first letter of the first name, followed by the first 4 letters of the last name, followed by the last two digits of the birth year. The first two letters of the username should be capitalized, and the remaining letters should be lower cased.
d) Write a function called isValidNumber() that prompts the user to enter three separate pieces of information to store in variables: the minimum value, the maximum value, and a third number of the user's choice. The function should then display to div4whether the third number entered is within the range of the first two numbers entered.