Question: Create a JavaScript file (link it to an HTML file), and write code for below 3 tasks: A. Apply switch statement, print out 'coffee





Create a JavaScript file (link it to an HTML file), and write code for below 3 tasks: A. Apply switch statement, print out 'coffee + bagel + Sandwich' if meal is breakfast or lunch; print out 'pasta' if meal is dinner, otherwise print 'no food' B1: Improve the microwave function which take arguments of food weight, time and mode, and display a message of the food weight and time needed for 4 persons under the mode. HINT: Create two more functions (for calculating food weight/ time for 4 persons) inside microwave function, and consider the case when user passes invalid input. B2: Jason wants to build a very simple tip calculator for whenever he goes eating in a restaurant. In his country, it's usual to tip 15% if the bill value is between 30 and 300. If the value is different, the tip is 20%. 1. Your task is to calculate the tip, depending on the bill value. Create a variable called 'tip' for this. Try not to use an if/else statement. 2. Print a string to the console containing the bill value, the tip, and the final value (bill+tip). Example: 'The bill was 275, the tip was 41.25, and the total value 316.25" * TEST DATA: Test for bill values 275, 28 and 430 C. Back to the two teams game! There is a new discipline, which works differently. Each team competes 3 times, and then the average of the 3 scores is calculated (so one average score per team). A team ONLY wins if it has at least DOUBLE the average score of the other team. Otherwise, no team wins! 1. Create an arrow function 'calcAverage' to calculate the average of 3 scores 2. Use the function to calculate the average for both teams 3. Create a function 'checkWinner' that takes the average score of each team as parameters ('avgNets' and 'avgKnicks'), and then logs the winner to the console, together with the victory points, according to the rule above. Example: "Knicks win (30 vs. 13)". 4. Use the 'checkWinner' function to determine the winner for both DATA 1 and DATA 2. 5. Ignore draws this time. TEST DATA 1: Nets score 44, 23 and 71. Knicks score 65, 54 and 49 TEST DATA 2: Nets score 85, 54 and 41. Knicks score 23, 34 and 27 D (Optional) Create a function called celsiusToFahrenheit: 1. Store a celsius temperature into a variable. Convert it to fahrenheit and output "NNC is NNF". Create a function called fahrenheitToCelsius; 2. Store a fahrenheit temperature into a variable. Convert it to celsius and output "NNF is NNC." var Lucas_Mass= 95; var Lucas Height=1.88; var Johan_Mass=85; var Johan Height=1.77; var BMI_Lucas= Lucas_Mass /Lucas_Height*Lucas_Height; var BMI_Johan= Johan_Mass /Johan_Height*Johan_Height; var lucasHiger BMI = Boolean (BMI_Lucas >BMI_Johan); document.getElementById("Problem1").innerHTML =lucasHiger BMI; //Problem 2 var C = parseInt(prompt('Enter the temperature in Celsius ')); var C_to_F= C*9/5+32; var F = parseInt(prompt('Enter the temperature in fahrenheit ')); var F_to_C = (F-32)*5/9; //console.log( `$C C $(C_to_F) F`); document.getElementById("Problem2_1").innerHTML =C_to_F; //console.log(`$F F $(F_to_C) C`); document.getElementById("Problem2_2").innerHTML =F_to_C; //Problem 3 var Net_1 = ')); parseInt(prompt('Enter the Nets 1 Score var Net_2 = parseInt(prompt('Enter the Nets 2 Score ')); var Net_3 = parseInt(prompt('Enter the Nets 3 Score ')); var Knicks_1 = Score ')); var Knicks_2 = Score ')); var Knicks_3 = Score ')); parseInt(prompt('Enter the Knicks 1 parseInt(prompt('Enter the Knicks 2 parseInt(prompt('Enter the Knicks 3 var Net Team_Avg= (Net_1+Net_2+Net_3)/3; var Knicks Team_Avg= (Knicks_1+Knicks_2+Knicks_3)/3; if (Net_Team_Avg >Knicks_Team_Avg) { document.getElementById("Problem3_1").innerHTML ="Nets Team Win"; }else if (Net_Team_Avg =100 && Knicks_Team_Total>=100 ) { //document.write (" "); document.write(" "); if (Net_Team_Total>Knicks_Team_Total){ document.getElementById("Problem3 2").innerHTML var Knicks_Team_Avg= (Knicks_1+Knicks_2+Knicks_3)/3; if (Net_Team_Avg >Knicks_Team_Avg) { document.getElementById("Problem3_1").innerHTML ="Nets Team Win"; }else if (Net_Team_Avg =100 && Knicks_Team_Total>=100 ) { //document.write (" "); document.write(" "); if (Net_Team_Total>Knicks_Team_Total){ document.getElementById("Problem3_2").innerHTML ="Nets Team Win"; }else if (Net_Team_Total Create a JavaScript file (link it to an HTML file), and write code for below 3 tasks: A. Apply switch statement, print out 'coffee + bagel + Sandwich' if meal is breakfast or lunch; print out 'pasta' if meal is dinner, otherwise print 'no food' B1: Improve the microwave function which take arguments of food weight, time and mode, and display a message of the food weight and time needed for 4 persons under the mode. HINT: Create two more functions (for calculating food weight/ time for 4 persons) inside microwave function, and consider the case when user passes invalid input. B2: Jason wants to build a very simple tip calculator for whenever he goes eating in a restaurant. In his country, it's usual to tip 15% if the bill value is between 30 and 300. If the value is different, the tip is 20%. 1. Your task is to calculate the tip, depending on the bill value. Create a variable called 'tip' for this. Try not to use an if/else statement. 2. Print a string to the console containing the bill value, the tip, and the final value (bill + tip). Example: 'The bill was 275, the tip was 41.25, and the total value 316.25 * TEST DATA: Test for bill values 275, 28 and 430 C. Back to the two teams game! There is a new discipline, which works differently. Each team competes 3 times, and then the average of the 3 scores is calculated (so one average score per team). A team ONLY wins if it has at least DOUBLE the average score of the other team. Otherwise, no team wins! 1. Create an arrow function 'calcAverage' to calculate the average of 3 scores 2. Use the function to calculate the average for both teams 3. Create a function 'checkWinner' that takes the average score of each team as parameters ('avgNets' and 'avgKnicks'), and then logs the winner to the console, together with the victory points, according to the rule above. Example: "Knicks win (30 vs. 13)". 4. Use the 'checkWinner' function to determine the winner for both DATA 1 and DATA 2. 5. Ignore draws this time. TEST DATA 1: Nets score 44, 23 and 71. Knicks score 65, 54 and 49 TEST DATA 2: Nets score 85, 54 and 41. Knicks score 23, 34 and 27 D (Optional) Create a function called celsiusToFahrenheit 1. Store a celsius temperature into a variable. Convert it to fahrenheit and output "NNC is NN"F". Create a function called fahrenheitToCelsius; 2 Store a fahrenheit temperature into a variable. Convert it to celsius and output "NNF is NN"C"
Step by Step Solution
There are 3 Steps involved in it
Sure Heres the JavaScript code for the tasks youve mentioned Make sure to link it with an appropriat... View full answer
Get step-by-step solutions from verified subject matter experts
