Coding Quiz - JavaScript Review

// Problem 1: Write a function that takes two numbers // as arguments and returns their sum. const addNumbers = (n1, n2) => { return n1 + n2; }; //Problem 2: // Prompt the user to enter their favorite food. // Then write an IF statement that does the following: // If the user enters "pizza", then log "We have pizza!" to the console. // If the user enters "ice cream", then log "We have ice cream!" to the console. // If the user enters anything else, log "Sorry, we don't have that." to the console. const input = prompt("What is your favorite food?"); if(input == "pizza"){ console.log("We have pizza!"); }else if(input == "ice cream"){ console.log("We have ice cream!"); }else{ console.log("Sorry, we don't have that!"); } //Problem 3: Loop through the array below and log the current element: var fruits = ["apple", "banana", "cherry", "date", "elderberry"]; for(let x = 0; x < fruits.length; x++){ console.log(fruits[x]); }

Copy everything in the gray box below and paste it into a ChatGPT prompt to see how well you did (or click here to copy everything to your clipboard).