Pergunta de entrevista da empresa Lanyon

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

Respostas da entrevista

Sigiloso

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; }

Sigiloso

18 de dez. de 2020

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

Sigiloso

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