JavaScript | 자바스크립트 | INTRODUCTION TO JAVASCRIPT 네번째
JavaScript | 자바스크립트 | INTRODUCTION TO JAVASCRIPT 네번째
Getting Started with Programming | Codecademy
18/28 Mid-lesson breather
File1 _ script.js
// This is an example of an if / else statement.if (12 / 4 === "Ari".length) {
confirm("Will this run the first block?");
} else {
confirm("Or the second block?");
}
19/28 Math
File1 _ script.js
if ("Jon".length * 2 / (2+1) === 2){
console.log("The answer makes sense!");
}
else {
console.log("Error Error Error");
}
20/28 Math and the modulo
File1 _ script.js
// Below is an example of printing the remainder of 18/4 using modulo:
// console.log(18 % 4);
console.log(14%3);
console.log(99 % 8);
console.log(11 % 3);
21/28 Modulo and if / else
File1 _ script.js
//An example of an if/else statement with modulo in the condition
if( 13 % 2 ) {
console.log("The first number is even");
} else {
console.log("The first number is odd");
}
22/28 Substrings
File1 _ script.js
// Be careful with the substring's letter positions!
"wonderful day".substring(3,7);
23/28 More substring practice
File1 _ script.js
// Use console.log( ) to print out the substrings.
// Here is an example of the 1st to 4th letter of "JavaScript":
// console.log("JavaScript".substring(0,4));
console.log("January".substring(0,3));
console.log("Melbourne is great".substring(0,12));
console.log("Hamburgers".substring(3,10));
Next: Variables
