Javascript interview machine coding question. Array-based machine coding JS interview question.
Write a JS code that takes an array of words in small letters and returns an array with the same word’s first letters in uppercase.
['sydney','melbourne','brisbane','newyork'] should return [ 'Sydney', 'Melbourne', 'Brisbane', 'Newyork' ]
Solution
let arr = ['sydney','melbourne','brisbane','newyork']
arr = arr.map(a => {
let letters = a.split('')
letters[0] = letters[0].toUpperCase();
return letters.join("");
})
console.log(arr)