본문 바로가기

공부자료/자바스크립트

(19)
Coding Challenge - sum by looping const calcTip = function (bill) { return bill >= 50 && bill
섹션 2 Javascript Fundamentals part 2 - The While Loop /////////////////////////////////////// // The while Loop for (let rep = 1; rep
섹션 2 Javascript Fundamentals part 2 - Looping Backwards and Loops in Loops /////////////////////////////////////// // Looping Backwards and Loops in Loops const jonas = [ 'Jonas', 'Schmedtmann', 2037 - 1991, 'teacher', ['Michael', 'Peter', 'Steven'], true ]; // 0, 1, ..., 4 // 4, 3, ..., 0 for (let i = jonas.length - 1; i >= 0; i--) { console.log(i, jonas[i]); } for (let exercise = 1; exercise < 4; exercise++) { console.log(`-------- Starting exercise ${exercise}`); fo..
섹션 2 Javascript Fundamentals part 2 - Looping Arrays, Breaking and Continuing /////////////////////////////////////// // Looping Arrays, Breaking and Continuing const jonas = [ 'Jonas', 'Schmedtmann', 2037 - 1991, 'teacher', ['Michael', 'Peter', 'Steven'], true ]; const types = []; // console.log(jonas[0]) // console.log(jonas[1]) // ... // console.log(jonas[4]) // jonas[5] does NOT exist for (let i = 0; i < jonas.length; i++) { // Reading from jonas array console.log(jon..
섹션 2 Javascript Fundamentals part 2 - Iteration: The for Loop /////////////////////////////////////// // Iteration: The for Loop // console.log('Lifting weights repetition 1 🏋️‍♀️'); // console.log('Lifting weights repetition 2 🏋️‍♀️'); // console.log('Lifting weights repetition 3 🏋️‍♀️'); // console.log('Lifting weights repetition 4 🏋️‍♀️'); // console.log('Lifting weights repetition 5 🏋️‍♀️'); // console.log('Lifting weights repetition 6 🏋️‍♀️'); // cons..
섹션 2 Javascript Fundamentals part 2 - Object Methods /////////////////////////////////////// // Object Methods const jonas = { firstName: 'Jonas', lastName: 'Schmedtmann', birthYeah: 1991, job: 'teacher', friends: ['Michael', 'Peter', 'Steven'], hasDriversLicense: true, // calcAge: function (birthYeah) { // return 2037 - birthYeah; // } // calcAge: function () { // // console.log(this); // return 2037 - this.birthYeah; // } calcAge: function () { ..
섹션 2 Javascript Fundamentals part 2 - Dot vs Bracket Notation /////////////////////////////////////// // Dot vs. Bracket Notation const jonas = { firstName: 'Jonas', lastName: 'Schmedtmann', age: 2037 - 1991, job: 'teacher', friends: ['Michael', 'Peter', 'Steven'] }; console.log(jonas); console.log(jonas.lastName); console.log(jonas['lastName']); const nameKey = 'Name'; console.log(jonas['first' + nameKey]); console.log(jonas['last' + nameKey]); // console..
섹션 2 Javascript Fundamentals part 2 - Introduction to Objects /////////////////////////////////////// // Introduction to Objects const jonasArray = [ 'Jonas', 'Schmedtmann', 2037 - 1991, 'teacher', ['Michael', 'Peter', 'Steven'] ]; const jonas = { firstName: 'Jonas', lastName: 'Schmedtmann', age: 2037 - 1991, job: 'teacher', friends: ['Michael', 'Peter', 'Steven'] };
섹션 2 Javascript Fundamentals part 2 - Basic Array Operations /////////////////////////////////////// // Basic Array Operations (Methods) const friends = ['Michael', 'Steven', 'Peter']; // Add elements const newLength = friends.push('Jay'); console.log(friends); console.log(newLength); friends.unshift('John'); console.log(friends); // Remove elements friends.pop(); // Last const popped = friends.pop(); console.log(popped); console.log(friends); friends.shi..