0

before[0] is definitely uppercased, so I’m confused why it’s evaluating to false

function myReplace(str, before, after) {
    console.log(before[0] === before[0].toUpperCase();
}

myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");
hteml
  • 43
  • 3
  • Just copy @marvel308's answer. – doubleOrt Sep 24 '17 at 21:45
  • Possible duplicate of [Check if first letter of word is a capital letter](https://stackoverflow.com/questions/8334606/check-if-first-letter-of-word-is-a-capital-letter) – wp78de Sep 25 '17 at 00:48

3 Answers3

1

you were referring to the function toUpperCase. you need to call it in order to get the value

function myReplace(str, before, after) {
    console.log(before[0] === before[0].toUpperCase());
}

myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");
marvel308
  • 10,288
  • 1
  • 21
  • 32
0

This time you forgot to close the console.log, it should be:

  function myReplace(str, before, after) {
    console.log(before[0] === before[0].toUpperCase());
}

myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");
doubleOrt
  • 2,407
  • 1
  • 14
  • 34
0

Hell, you should add parentheses :

function myReplace(str, before, after) {
    console.log(before[0] === before[0].toUpperCase());
}

myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");
Slim KTARI
  • 294
  • 2
  • 9