Asked by Anonymous
There is a Mad Lib story written in the editor. It has been broken down into two parts:
Ask the user for input and store the values in variables
Print the story with the variables created in step 1
Step 2 has been done for you. You need to complete step 1. Look at the variables used in the story so that you know which variables you need to declare and get user input for.
A sample run may look like the following:
Name: George
Plural noun: cows
Holiday: Valentine's Day
Hi George, it's so good to meet you!
I'm having a Valentine's Day themed party at
at my house. You need to bring your own cows
with you. I hope you join us!
Plain text
Status: Not Submitted
2.4.5 Create a Story
default.js
main();
function main() {
// -----> Gather the user input that is needed to complete the
// story below. Remember to store the input into the appropriate
// variables so that they can be used in the story.
// Print the story:
console.log();
console.log("Hi " + name + ", it's so good to meet you!");
console.log("I'm having a " + holiday + " themed party at");
console.log("at my house. You need to bring your own " + pluralNoun);
console.log("with you. I hope you join us!");
}
main();
All Answers 1
Answered by
GPT-5 mini
AI
function main() {
// -----> Gather the user input that is needed to complete the
// story below. Remember to store the input into the appropriate
// variables so that they can be used in the story.
// Use getInput if available (Codecademy), otherwise fall back to prompt
var ask = (typeof getInput === 'function') ? getInput : prompt;
var name = ask("Name: ");
var pluralNoun = ask("Plural noun: ");
var holiday = ask("Holiday: ");
// Print the story:
console.log();
console.log("Hi " + name + ", it's so good to meet you!");
console.log("I'm having a " + holiday + " themed party at");
console.log("at my house. You need to bring your own " + pluralNoun);
console.log("with you. I hope you join us!");
}
main();
// -----> Gather the user input that is needed to complete the
// story below. Remember to store the input into the appropriate
// variables so that they can be used in the story.
// Use getInput if available (Codecademy), otherwise fall back to prompt
var ask = (typeof getInput === 'function') ? getInput : prompt;
var name = ask("Name: ");
var pluralNoun = ask("Plural noun: ");
var holiday = ask("Holiday: ");
// Print the story:
console.log();
console.log("Hi " + name + ", it's so good to meet you!");
console.log("I'm having a " + holiday + " themed party at");
console.log("at my house. You need to bring your own " + pluralNoun);
console.log("with you. I hope you join us!");
}
main();
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.