Skip to content
Sign upLog in
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
2

How to solve this?

rudy35hernandez
rudy35hernandez

I am stumped on this question. I re-read the entire lesson plan and I am still unable to solve this. Any ideas?

function lottoTicket(age) {
const valid = "Thanks for your purchase!"
const invalid = "Purchase denied. Try again when you're older."
if(age > 18) {
return(valid)
}
else {
return(invalid)
}
}

ageAlice = 12

ageBob = 20

// declare a variable to save Alice's lottoTicket autoresponse and another to save Bob's lottoTicket autoresponse

2 years ago
You are viewing a single comment. View All
2
Coder100
Coder100

Hi! You haven't done anything with the function yet. Does this work?

function lottoTicket(age) { const valid = "Thanks for your purchase!" const invalid = "Purchase denied. Try again when you're older." if(age > 18) { return(valid) } else { return(invalid) } } let ageAlice = 12; let ageBob = 20; // declare a variable to save Alice's lottoTicket autoresponse and another to save Bob's lottoTicket autoresponse let alicelottoTicket = lottoTicket(ageAlice); let boblottoTicket = lottoTicket(ageBob); console.log("Alice's result:", alicelottoTicket); // Alice's result: Purchase denied. Try again when you're older. console.log("Bob's result:", boblottoTicket); // Bob's result: Thanks for your purchase!
2 years ago