2017-09-24 19 views
0

[0]は間違いなく大文字される前に、それはあなたが関数のtoUpperCaseを参照して偽チェック、解決策が偽の評価

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

myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped"); 
+0

@ marvel308の答えをコピーしてください。 – Taurus

+0

[単語の最初の文字が大文字であるかどうか](https://stackoverflow.com/questions/8334606/check-if-first-letter-of-word-is-a-capitalletter)の可能な複製 – wp78de

答えて

1

に評価している理由、私は混乱しています。あなたが値

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

 
myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");

0

あなたがconsole.logを閉じるのを忘れて、この時間を得るためにそれを呼び出す必要があり、それは次のようになります。

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

myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped"); 
0

地獄、あなたは括弧を追加する必要があります:

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

myReplace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped"); 
関連する問題