This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Prime - Factors are only and itself | |
| // Composite - Can be divided evenly by its factors | |
| // 12 = 1, 2, 3, 4, 6, 12 | |
| // 11 = 1, 11 - Prime | |
| // 13 = 1, 13 - Prime | |
| const showPrimes = (limit) => { | |
| for (let number = 2; number <= limit; number++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // In this exercise, we want to calculate the grade of a student. | |
| // Calculate the average grade | |
| // If the average is 1-59: F | |
| // 60-69: D | |
| // 70-79: C | |
| // 80-89: B | |
| // 90-100: A | |
| const marks = [80, 80, 50] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Speed Limit = 70 | |
| // If the car is driving under the speed limit, we get an OK message. | |
| // If the car is driving exactly at the speed limit, it's still OK. | |
| // Now, for every 5 kilometers above the speed limit, they're going to get 1 point. Let's say, if I drive 75 km per hour, you get 1 point. | |
| // What if I drive 72 km per hour? Still good. For every 5 km above the speed limit, we should give the driver 1 point. | |
| // Use Math.floor(), we can give a function a floating point number and this will convert that to the greatest integer. | |
| // What if you passed 80 km per hour? The driver should get 2 points. | |
| // Now, what if we drive at 180 km per hour? The driver's license should be suspended. | |
| // If the driver gets more than 12 points, their license should be suspended. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isLandscape(width, height) { | |
| return width > height | |
| } | |
| console.log(isLandscape(400, 360)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const output = fizzBuzz("a") | |
| console.log(output) | |
| function fizzBuzz(input) { | |
| if (typeof input !== "number") return NaN | |
| if (input % 3 === 0 && input % 5 === 0) return "fizzBuzz" | |
| if (input % 3 === 0) return "Fizz" | |
| if (input % 5 === 0) return "Buzz" | |
| return input | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let number = max(35, 35) | |
| function max(num1, num2) { | |
| return num1 > num2 ? num1 : num2 | |
| } | |
| console.log(number) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // At a restaurant, you order 1 soup for $10, 3 burgers for $8 each, 1 ice cream for $5. | |
| const soup = 10 | |
| const burger = 8 | |
| const iceCream = 5 | |
| const totalCost = soup + (burger * 3) + iceCream | |
| console.log(totalCost) // Output: $39.00 | |
| // You're at a restaurant with 2 friends (3 people in total) and make the same order. Calculate how much each person pays. | |
| totalCost * 3 // Output: $117 | |
| // Divided to 3 people, since they ordered the same. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // alert('Good Morning') | |
| // alert('Hello, Dan!') | |
| console.log(10 + 5) | |
| console.log(20 - 5) | |
| console.log(2 + 2 - 5) | |
| // document.body.innerHTML("Good Morning!") | |
| // document.body.innerHTML("Good Morning, Dan!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let customer = { | |
| customer_name: "Johnny Manggo", | |
| points: 12300, | |
| cart: [ | |
| { | |
| item: "Shampoo", | |
| quantity: 2, | |
| price_$: 3, | |
| }, | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Reference: http://lea.verou.me/2011/10/easily-keep-gh-pages-in-sync-with-master/ | |
| $ git add . | |
| $ git status // to see what changes are going to be commited | |
| $ git commit -m 'Some descriptive commit message' | |
| $ git push origin master | |
| $ git checkout gh-pages // go to the gh-pages branch | |
| $ git rebase master // bring gh-pages up to date with master | |
| $ git push origin gh-pages // commit the changes |