0

I need help for writing this JavaScript function in Python.

  • Write a javascript function that accepts a string as a parameter and converts the first letter of each word of the string in upper case. e.g 'the quick brown fox'

EXPECTED OUTPUT: 'The Quick Brown Fox'

What I wrote so far:

function upperCase (str) {
  var array1 = str.split(' ');
  var newArray1 = [ ];

  for (var x = 0; x < array1.length; x++) {
        newArray1.push (array1[x].charAt(0).toUpperCase 
        ()+array1 [x].slice (1));
  }
   return newArray1.join (' ');
}
console.log (uppercase ("the quick brown fox"));
Eray Balkanli
  • 7,752
  • 11
  • 48
  • 82

0 Answers0