Trying "if-syntax" does not give correct result, what did i wrong?


#1



https://www.codecademy.com/courses/ruby-beginner-en-NFCZ7/0/2?curriculum_id=5059f8619189a5000201fbcb


comparison of String with 5 failed


print "insert a number"
answer = gets.chomp

x = answer
if x > 5
  print "I am big!"
elsif x == 5
  print "I am correct!"
else
  print "I am small!"
end


#2

You are trying to compare a string with a constant.

Either: Get an integer value as the input
Or: Put 5 between inverted commas.

example: if x > "5"

P.S. I don't know Ruby. But the answer is correct. :slight_smile:


#3

you are currently comparing a string to an integer


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.