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
1
EpicGamer007
EpicGamer007

when you return something, you have to do
return + the variable you want to return, your syntax is wrong.

@SixBeeps
's answer is correct as well.

Sorry for pinging you if you found it annoying...
2 years ago
1
SixBeeps
SixBeeps

@AbhayBhat
Nah, the syntax is fine
image

2 years ago
1
EpicGamer007
EpicGamer007

@SixBeeps
, oh ok, im just a js noob >_<

2 years ago
1
Coder100
Coder100

yeah, although return is like return value, the value can also be an expression, and (variable) is an expression. This is also why typeof "hi" and typeof("hi") works as well.

@AbhayBhat

2 years ago