728x90 반응형 SMALL programming375 chapter 3) Using conditional operators ### Script Breakdown - `const input = prompt('Number : ', '')`: This line displays a prompt dialog box asking the user to enter a number. The second parameter of `prompt` is the default text, which is set to an empty string here. The user's input is stored in the `input` variable. - `const number = Number(input)`: The user's input is converted to a number using the `Number` constructor. If the i.. 2024. 11. 27. chapter 3) Using switch conditional statements ### Breakdown of the JavaScript Code - `const input = Number(prompt('Number : ', 'Number'))`: This line displays a prompt dialog box asking the user to enter a number. The input is then converted to a number type using the `Number` constructor. If the input cannot be converted to a number, the result will be `NaN` (Not-a-Number). - `switch (input % 2)`: The modulo operator (`%`) is used to get t.. 2024. 11. 26. chapter 3) Using if conditional statements ### Code Description - The document starts with the standard `` declaration, indicating that this is an HTML5 document. - The `` element specifies the document's language as English (`lang="en"`). - Within the `` section, there's a `` tag that defines the character encoding for the document as UTF-8, ensuring that it can represent a wide variety of characters from different languages. - The `` t.. 2024. 11. 25. chapter 2) Example of using increment/decrement operators ### Script Overview - **First Example**: Demonstrates simple post-increment. - `number` is initially `10`, then incremented by 1 using `number++`. The `alert` shows `11`. - **Second Example**: Shows post-increment's effect when used before an `alert`. - `number1` starts at `10`, but `alert(number1++)` shows `10` because it returns the value before incrementing. Subsequent `alert` calls show `11`.. 2024. 11. 24. 이전 1 ··· 16 17 18 19 20 21 22 ··· 94 다음 728x90 반응형 LIST