When working with strings, you might want to ask true/false questions about them, and use
results of these questions in a if statement. These
questions often will involving checking if two strings are equal to one another, or if one may come before another
(alphabetically). To do this, you can use the same operators as for numbers, which are:
== to test for equality
~= to test for being not-equal
< to test if if a string comes before another alphabetically
> to test if if a string comes after another alphabetically
Now you try. Run this code and type in word when asked. Try words that come before and after computer alphabetically. Also
try typing in computer exactly.
Type your code here:
See your results here:
This code will work, but try to add this functionality: if the word typed is not equal to "computer" (i.e. ~=), display
the text "your word is not computer."
Share your code
Show a friend, family member, or teacher what you've done!