Input:
Aliquam ipsum ex, tempus ornare semper ac, varius vitae nibh.
Output:
A i e, t o s a, v v n.
I need a javascript function to solve this.
I'm trying something like this:
function short_verse(verse) {
let result = [];
verse.split(' ').map(word => word.charAt(0) != '' ? result.push(word.charAt(0)) : '');
return result.join(" ");
}
let input = "Aliquam ipsum ex, tempus ornare semper ac, varius vitae nibh.",
output = short_verse(input);
console.log(output);
The story: They say you can memorize texts this way. :) So, I create an application that will include this feature, too.
It should work for non-ascii chars, too. Example:
Input: Aliqușam țipsum ex, tempăs ornâre semper ac, varius vitae îbh.
Output: A ț e, t o s a, v v î
Note: In my case romanian diacritics would be enough - ăâîșțĂÂÎȘȚ.