初級 › 関数がreturn文を書き忘れてundefinedを返してしまう › パターン5
関数がreturn文を書き忘れてundefinedを返してしまう
計算結果を変数に入れても、return文で明示的に返さない限り、関数はundefinedを返します。
1 function shout(word) { 2 const message = word.toUpperCase(); 3 _____________________ ^ 4 } 5 console.log(shout("hi"));
出力: undefined期待: HI (エラーにはなりません)
空欄を埋めて実行を通す
文字列を大文字化しても、returnし忘れると外側からは見えません。
次の問題