null値を入力すると、警告が表示されない場合があることがわかります。引数には、すべての値がnullであってはならないことが示されます。そうでない場合、関数は終了します。null値と論理演算子が動作しない
誰にもアイデアはありますか?ありがとうございました!
@charset "UTF-8";
/* CSS Document */
body{
\t height:1000px;
\t width:100%;
\t background:#fff;
\t margin:0;
}
.divider{
\t width:100%;
\t height:auto;
\t background:#CCC;
\t display:block;
\t margin:10px;
}
h2{
\t font-size:16px;
\t display:block;
}
#confirm-paragraph{}
#global-variable-paragraph{}
#user-input{}
#expressions{}
#elephant-paragraph{}
#method-1{}
#method-2{}
#ml{}
#litres{}
#conditional-operator{}
#cast-1{}
#cast-2{}
<!-- Checklist: Obtain user input and store it in variables -->
<!-- Report variable text to the client window -->
<!-- Prompt -->
<section class="divider">
<h2>User Input Variables Example</h2>
<button onclick="nameFunction()">Click Me</button>
<p id="user-input">This text should change after clicking the button.</p>
<p style="color:red; font-weight:bold">NOT WORKING Version3!!!!!!!!</p>
<p>Should not alert if null values are present - null values are present by just clicking OK when entering nothing. All values should not be null in order for the alert to appear</p>
<script>
function nameFunction() {
\t var yourforename = prompt("What is your first name?");
\t var yoursurname = prompt("What is your last name?");
\t var yourage = prompt("What is your age?");
\t if (yourforename != null && yoursurname != null && yourage != null) {
\t alert("Hello " + yourforename + " " + yoursurname + ". You are " + yourage + " years old.");
\t }
}
</script>
</section>
に
を変更するには、あなたがprompt' 'に何も入力しない場合、それは空の文字列とnullではないが返されます。かなり確信することができまた、CSS/HTMLコードを削除して、両方の言語のタグを削除することもできます。 –