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!

10th Jul 2018, 1:43 PM
B.D
B.D - avatar
8 ответов
+ 2
Which language?
10th Jul 2018, 1:46 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 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
10th Jul 2018, 1:56 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 2
JavaScript if(s.charAt(0)==s.slice(-1))
10th Jul 2018, 2:12 PM
Calviղ
Calviղ - avatar
+ 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;
10th Jul 2018, 1:48 PM
Jonas Schröter
Jonas Schröter - avatar
+ 1
thank you
10th Jul 2018, 2:13 PM
B.D
B.D - avatar
0
thank you
10th Jul 2018, 2:01 PM
B.D
B.D - avatar
0
thank you
10th Jul 2018, 2:07 PM
B.D
B.D - avatar
0
Which language? if(s.charAt(0)==s.slice(-1))
10th Jul 2018, 2:13 PM
B.D
B.D - avatar