Ask coding questions

← Back to all posts
What do I do so it does't say "yesOkay." in the console?
LANDONHALL (0)

Please help me with this.

Commentshotnewtop
PattanAhmed (1103)

@LANDONHALL Hi,
Change your code like this:-

io.write('Enter your name: ')
name_input = io.read()
io.write("Enter your age: ")
age_input = io.read()

io.write("Hello, " .. name_input .. ', you are ' .. age_input .. ' years old, is that correct?: ')

reply = io.read()
if reply == ('yes') then print('Okay!')

-- Additionally, I added this if you want you can remove it too:-
print(name_input)
end

That's it
Thanks!

Hope this helps

Coder100 (8720)

Because io.write('yes') will print out yes and then return true and so then it will print ok.

To solve the problem, compare reply1 instead of printing out the expected input smh

if reply1 == 'yes' then
print ('okay. ')
end
Wumi4 (94)

This is very simple to fix. On line 9 at your repl, fix with this line of code:

if reply1 == ('yes') then print(' Okay.')

Have a nice day!

Coder100 (8720)

what's with the ('yes')? Also why did you not end the if statement smh @DangHoang2