Help me please!! JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Help me please!! JavaScript

Como puedo hacer que una función retorne la primera letra de cada palabra en una frase? Por ejemplo:” Hey, can you help me please! “ y que retorne “Hcyhmp”??

5th Feb 2019, 7:16 AM
Jorge Arancibia
Jorge Arancibia - avatar
2 Answers
+ 3
alert(prompt("Enter a sentence:").split(" ").map(function(word) { return word.charAt(0); }).join("")); /* More detail here: alert(prompt("Enter a sentence:") // to get the input .split(" ") // to get each word (split by a space) .map(function(word) { return word.charAt(0); // for each word, only use the first character }).join("")); // join the array of first characters */
5th Feb 2019, 8:07 AM
Rowsej
Rowsej - avatar
+ 1
thank!!
6th Feb 2019, 9:24 AM
Jorge Arancibia
Jorge Arancibia - avatar