0
How can I create a code that'll print whether a word starts and ends with the same letter?
Like: Input:Wow Output:True Input:Vow Output:False Please help me!
8 odpowiedzi
+ 2
Which language?
+ 2
#ruby
word = gets.chomp.downcase
#Takes user input and converts it to lowercase
puts word
puts word[0] == word[-1]
# First Char | Last Char
+ 2
JavaScript
if(s.charAt(0)==s.slice(-1))
+ 1
You check which letter is the first. Then you compare it to the last one. For example in Java:
String word = "wow";
if(word.charAt(0) == word.charAt(word.length() - 1))return true;
else return false;
+ 1
thank you
0
thank you
0
thank you
0
Which language?
if(s.charAt(0)==s.slice(-1))