const assert = require('assert');
/*  Using the JavaScript language, have the function LetterCapitalize(str) take the str parameter being passed and capitalize the first letter of each word. Words will be separated by only one space. */
function letterCapitalize(str) { 
  
// Input:"i like coffee"
// Output:"I Like Coffee"

// Input:"i dance"
// Output:"I Dance"

  const arr = str.split("");
  let fl = true;
  for (let i = 0; i < arr.length; i++){
   if (fl) {
     const item = arr[i].toString();
       arr[i] = item.toUpperCase();
       fl = false;
   };
  
    if (arr[i] === " ") {
      fl = true;
    }
  }
  str = arr.join("");
  return str; 
}

const in1 = "i like coffee";
const expect1 = "I Like Coffee";
const test1 = letterCapitalize(in1);
assert.strictEqual(test1, expect1, `should be ${expect1}`);
   

const in2 = "i dance";
const expect2 = "I Dance";
const test2 = letterCapitalize(in2);
assert.strictEqual(test2, expect2, `should be ${expect2}`);

@@ -230,24 +230,21 @@
 ace. */%0A
-function
+const
  letterC
@@ -256,111 +256,19 @@
 lize
-(str) %7B %0A  %0A// Input:%22i like coffee%22%0A// Output:%22I Like Coffee%22%0A%0A// Input:%22i dance%22%0A// Output:%22I Dance%22%0A
+ = str =%3E %7B
 %0A  c
@@ -292,30 +292,13 @@
 lit(
-%22%22
+''
 );%0A
-  let fl = true;%0A
   fo
@@ -332,41 +332,27 @@
 h; i
-++)%7B%0A   if (fl) %7B%0A     const item
+ += 1) %7B%0A    arr%5Bi%5D
  = a
@@ -361,144 +361,73 @@
 %5Bi%5D.
-toS
+subs
 tring(
-);%0A       arr%5Bi%5D = item.toUpperCase();%0A       fl = false;%0A   %7D;%0A  %0A    if (arr%5Bi%5D === %22 %22) %7B%0A      fl = true
+0, 1).toUpperCase() + arr%5Bi%5D.substring(1)
 ;%0A  
- 
- 
 %7D%0A  
-%7D%0A  str =
+return
  arr
@@ -436,29 +436,15 @@
 oin(
-%22%22
+''
 );%0A
-  return str; %0A
 %7D
+;
 %0A%0Aco
@@ -453,17 +453,17 @@
 t in1 = 
-%22
+'
 i like c
@@ -463,25 +463,25 @@
  like coffee
-%22
+'
 ;%0Aconst expe
@@ -486,17 +486,17 @@
 pect1 = 
-%22
+'
 I Like C
@@ -500,17 +500,17 @@
 e Coffee
-%22
+'
 ;%0Aconst 
@@ -599,20 +599,16 @@
 ect1%7D%60);
-%0A   
 %0A%0Aconst 
@@ -617,17 +617,17 @@
 2 = 
-%22
+'
 i dance
-%22
+'
 ;%0Aco
@@ -644,17 +644,17 @@
 2 = 
-%22
+'
 I Dance
-%22
+'
 ;%0Aco
@@ -744,12 +744,104 @@
 expect2%7D%60);%0A
+%0A// Input:%22i like coffee%22%0A// Output:%22I Like Coffee%22%0A%0A// Input:%22i dance%22%0A// Output:%22I Dance%22%0A

change function and update to es6