Pregunta de entrevista de Lanyon

Write a function to print the first letter of every word in a string.

Respuestas de entrevistas

Anónimo

17 de abr de 2017

public String getFirstLetters(String text) { String firstLetters = ""; text = text.replaceAll("[.,]", ""); // Replace dots, etc (optional) for(String s : text.split(" ")) { firstLetters += s.charAt(0); } return firstLetters; }

Anónimo

18 de dic de 2020

let sentence = 'Big Green Dog' let words = sentence.split(' ') words.map((word) =>{ word.split('') console.log(word[0]) }) //output "B" "G" "D"

Anónimo

26 de jul de 2015

public void firstLetter(String s){ if (s.length()==0) return; for (String retval: s.split(" ")){ System.out.println(retval[0]); } }

1