diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..d39315a7 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,93 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to Edge", + "port": 9222, + "request": "attach", + "type": "msedge", + "webRoot": "${workspaceFolder}" + }, + { + "name": "Attach to Chrome", + "port": 9222, + "request": "attach", + "type": "chrome", + "webRoot": "${workspaceFolder}" + }, + { + "name": "Launch Chrome", + "request": "launch", + "type": "chrome", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + }, + { + "name": "Attach to Chrome", + "port": 9222, + "request": "attach", + "type": "chrome", + "webRoot": "${workspaceFolder}" + }, + { + "type": "chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + }, + { + "type": "pwa-msedge", + "name": "Launch Microsoft Edge", + "request": "launch", + "runtimeArgs": [ + "--remote-debugging-port=9222" + ], + "url": "/Users/veronika/.vscode/extensions/ms-edgedevtools.vscode-edge-devtools-2.1.1/out/startpage/index.html", // Provide your project's url to finish configuring + "presentation": { + "hidden": true + } + }, + { + "type": "pwa-msedge", + "name": "Launch Microsoft Edge in headless mode", + "request": "launch", + "runtimeArgs": [ + "--headless", + "--remote-debugging-port=9222" + ], + "url": "/Users/veronika/.vscode/extensions/ms-edgedevtools.vscode-edge-devtools-2.1.1/out/startpage/index.html", // Provide your project's url to finish configuring + "presentation": { + "hidden": true + } + }, + { + "type": "vscode-edge-devtools.debug", + "name": "Open Edge DevTools", + "request": "attach", + "url": "/Users/veronika/.vscode/extensions/ms-edgedevtools.vscode-edge-devtools-2.1.1/out/startpage/index.html", // Provide your project's url to finish configuring + "presentation": { + "hidden": true + } + } + ], + "compounds": [ + { + "name": "Launch Edge Headless and attach DevTools", + "configurations": [ + "Launch Microsoft Edge in headless mode", + "Open Edge DevTools" + ] + }, + { + "name": "Launch Edge and attach DevTools", + "configurations": [ + "Launch Microsoft Edge", + "Open Edge DevTools" + ] + } + ] +} \ No newline at end of file diff --git a/1. Build a Passenger Counter App/1. Welcome to the course/index.css b/1. Build a Passenger Counter App/1. Welcome to the course/index.css index a99ee492..9bf45931 100644 --- a/1. Build a Passenger Counter App/1. Welcome to the course/index.css +++ b/1. Build a Passenger Counter App/1. Welcome to the course/index.css @@ -1,4 +1,6 @@ html, body { margin: 0; padding: 0; + text-align: center; + font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; } \ No newline at end of file diff --git a/1. Build a Passenger Counter App/1. Welcome to the course/index.html b/1. Build a Passenger Counter App/1. Welcome to the course/index.html index 264d9b51..1a9dd6b3 100644 --- a/1. Build a Passenger Counter App/1. Welcome to the course/index.html +++ b/1. Build a Passenger Counter App/1. Welcome to the course/index.html @@ -1,9 +1,12 @@ - + + + Passanger Counter -

index.html

- +

People Entered:

+

0

+ diff --git a/1. Build a Passenger Counter App/1. Welcome to the course/index.js b/1. Build a Passenger Counter App/1. Welcome to the course/index.js index 707e5c56..78ceb154 100644 --- a/1. Build a Passenger Counter App/1. Welcome to the course/index.js +++ b/1. Build a Passenger Counter App/1. Welcome to the course/index.js @@ -1 +1 @@ -// javascript \ No newline at end of file +document.getElementById("people-count").innerText = 80; \ No newline at end of file diff --git a/1. Build a Passenger Counter App/22. Render a welcome message/index.js b/1. Build a Passenger Counter App/22. Render a welcome message/index.js index 5781a6c2..15218e77 100644 --- a/1. Build a Passenger Counter App/22. Render a welcome message/index.js +++ b/1. Build a Passenger Counter App/22. Render a welcome message/index.js @@ -1,6 +1,19 @@ // Grab the welcome-el paragraph and store it in a variable called welcomeEl +let welcomeEl = document.getElementById("welcome-el"); // Create two variables (name & greeting) that contains your name // and the greeting we want to render on the page +let name = "Wendy" +let greeting = "Welcome back" + // Render the welcome message using welcomeEl.innerText +welcomeEl.innerText = greeting + ", " + name; + +// Add emoji to the end of the welcome message + +welcomeEl.innerText += "😎"; + + + + diff --git a/1. Build a Passenger Counter App/my-work/index.css b/1. Build a Passenger Counter App/my-work/index.css new file mode 100644 index 00000000..18a5ec65 --- /dev/null +++ b/1. Build a Passenger Counter App/my-work/index.css @@ -0,0 +1,37 @@ +body { + background-image: url("./station.jpg"); + background-size: cover; + font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; + font-weight: bold; + text-align: center; +} + +h1 { + margin-top: 10px; + margin-bottom: 10px; +} + +h2 { + font-size: 50px; + margin-top: 0; + margin-bottom: 20px; +} + +button { + border: none; + padding-top: 10px; + padding-bottom: 10px; + color: white; + font-weight: bold; + width: 200px; + margin-bottom: 5px; + border-radius: 5px; +} + +#increment-btn { + background: darkred; +} + +#save-btn { + background: darkgreen; +} diff --git a/1. Build a Passenger Counter App/my-work/index.html b/1. Build a Passenger Counter App/my-work/index.html new file mode 100644 index 00000000..672290c9 --- /dev/null +++ b/1. Build a Passenger Counter App/my-work/index.html @@ -0,0 +1,15 @@ + + + + + Passanger Counter + + +

People Entered:

+

0

+ + +

Previous entries:

+ + + diff --git a/1. Build a Passenger Counter App/my-work/index.js b/1. Build a Passenger Counter App/my-work/index.js new file mode 100644 index 00000000..ace8a634 --- /dev/null +++ b/1. Build a Passenger Counter App/my-work/index.js @@ -0,0 +1,16 @@ +let saveEl = document.getElementById("save-el"); +let countEl = document.getElementById("count-el"); +let count = 0; +console.log(7); + +function incrementButtonClick() { + count += 1; + countEl.textContent = count; +} + +function saveButtonClick() { + let previousEntries = count + " - "; + saveEl.textContent += previousEntries; + count = 0; + countEl.textContent = count; +} diff --git a/1. Build a Passenger Counter App/my-work/station.jpg b/1. Build a Passenger Counter App/my-work/station.jpg new file mode 100644 index 00000000..53fac691 Binary files /dev/null and b/1. Build a Passenger Counter App/my-work/station.jpg differ diff --git a/2. Practice time - part 1/1. Variables practice/index.js b/2. Practice time - part 1/1. Variables practice/index.js index 5c9017d1..e9558b5b 100644 --- a/2. Practice time - part 1/1. Variables practice/index.js +++ b/2. Practice time - part 1/1. Variables practice/index.js @@ -1,7 +1,10 @@ // Create two variables, firstName and lastName +let firstName = "Wendy"; +let lastName = "Jade"; // Concatenate the two variables into a third variable called fullName +let fullName = firstName + " " + lastName; // Log fullName to the console - +console.log(fullName); diff --git a/2. Practice time - part 1/2. Contatenate two strings in a function/index.js b/2. Practice time - part 1/2. Contatenate two strings in a function/index.js index 0d77f812..d3b03683 100644 --- a/2. Practice time - part 1/2. Contatenate two strings in a function/index.js +++ b/2. Practice time - part 1/2. Contatenate two strings in a function/index.js @@ -3,3 +3,8 @@ let greeting = "Hi there" // Create a function that logs out "Hi there, Linda!" when called +function myGreeting() { + console.log(greeting + ", " + name + "!"); +} + +myGreeting(); \ No newline at end of file diff --git a/2. Practice time - part 1/3. Incrementing and decrementing/index.js b/2. Practice time - part 1/3. Incrementing and decrementing/index.js index c8ef6908..ab32f947 100644 --- a/2. Practice time - part 1/3. Incrementing and decrementing/index.js +++ b/2. Practice time - part 1/3. Incrementing and decrementing/index.js @@ -3,8 +3,21 @@ let myPoints = 3 // Create two functions, add3Points() and remove1Point(), and have them // add/remove points to/from the myPoints variable +function add3Points() { + myPoints += 3; +} +function remove1Point() { + myPoints -= 1; +} +for (i = 0; i < 3; i++) { + add3Points() +} + +for (x = 0; x < 2; x++) { + remove1Point() +} // Call the functions to that the line below logs out 10 console.log(myPoints) \ No newline at end of file diff --git a/2. Practice time - part 1/4. Strings and numbers/index.js b/2. Practice time - part 1/4. Strings and numbers/index.js index 5b65455a..13cc84a3 100644 --- a/2. Practice time - part 1/4. Strings and numbers/index.js +++ b/2. Practice time - part 1/4. Strings and numbers/index.js @@ -1,7 +1,7 @@ // Try to predict what each of the lines will log out -console.log("2" + 2) // -console.log(11 + 7) // -console.log(6 + "5") // -console.log("My points: " + 5 + 9) // -console.log(2 + 2) // -console.log("11" + "14") // +console.log("2" + 2) // 22 +console.log(11 + 7) // 18 +console.log(6 + "5") // 65 +console.log("My points: " + 5 + 9) // 59 +console.log(2 + 2) // 4 +console.log("11" + "14") // 1114 diff --git a/2. Practice time - part 1/5. Rendering an error message/index.html b/2. Practice time - part 1/5. Rendering an error message/index.html index 220b3fc7..dfc2b00e 100644 --- a/2. Practice time - part 1/5. Rendering an error message/index.html +++ b/2. Practice time - part 1/5. Rendering an error message/index.html @@ -5,7 +5,7 @@ Nike shoe

Nike shoe

- +

diff --git a/2. Practice time - part 1/5. Rendering an error message/index.js b/2. Practice time - part 1/5. Rendering an error message/index.js index 46b0ffbc..31ab7aae 100644 --- a/2. Practice time - part 1/5. Rendering an error message/index.js +++ b/2. Practice time - part 1/5. Rendering an error message/index.js @@ -1,5 +1,13 @@ // When the user clicks the purchase button, render out // "Something went wrong, please try again" in the paragraph -// that has the id="error". +// that has the id="error" + +let errorEl = document.getElementById("error"); +console.log(errorEl); + +function displayMessage() { + errorEl.textContent = "Something went wrong, please try again"; +} + diff --git a/2. Practice time - part 1/6. Calculator challenge/index.html b/2. Practice time - part 1/6. Calculator challenge/index.html index ca440294..7464c6d3 100644 --- a/2. Practice time - part 1/6. Calculator challenge/index.html +++ b/2. Practice time - part 1/6. Calculator challenge/index.html @@ -6,12 +6,12 @@
- - - - + + + +
- Sum: + \ No newline at end of file diff --git a/2. Practice time - part 1/6. Calculator challenge/index.js b/2. Practice time - part 1/6. Calculator challenge/index.js index be36a2e4..24cb9752 100644 --- a/2. Practice time - part 1/6. Calculator challenge/index.js +++ b/2. Practice time - part 1/6. Calculator challenge/index.js @@ -4,6 +4,29 @@ document.getElementById("num1-el").textContent = num1 document.getElementById("num2-el").textContent = num2 // Create four functions: add(), subtract(), divide(), multiply() + +let sumEl = document.getElementById("sum-el"); + +function add() { + numSum = num1 + num2; + sumEl.textContent = "Result: " + numSum; +} + +function subtract() { + numSub = num1 - num2; + sumEl.textContent = "Result: " + numSub; +} + +function divide() { + numDiv = num1 / num2; + sumEl.textContent = "Result: " + numDiv; +} + +function multiply() { + numMult = num1 * num2; + sumEl.textContent = "Result: " + numMult; +} + // Call the correct function when the user clicks on one of the buttons // Perform the given calculation using num1 and num2 // Render the result of the calculation in the paragraph with id="sum-el" diff --git a/3. Build a Blackjack game/10. Add the message variable/index.js b/3. Build a Blackjack game/10. Add the message variable/index.js index 73da65de..2f6e2a36 100644 --- a/3. Build a Blackjack game/10. Add the message variable/index.js +++ b/3. Build a Blackjack game/10. Add the message variable/index.js @@ -1,19 +1,21 @@ let firstCard = 10 -let secondCard = 11 -let sum = firstCard + secondCard + 4 +let secondCard = 4 +let sum = firstCard + secondCard let hasBlackJack = false let isAlive = true // 1. Declare a variable called message and assign its value to an empty string +let message = ""; // 2. Reassign the message variable to the string we're logging out if (sum <= 20) { - console.log("Do you want to draw a new card? 🙂") + message = "Do you want to draw a new card? 🙂"; } else if (sum === 21) { - console.log("Wohoo! You've got Blackjack! 🥳") + message = "Wohoo! You've got Blackjack! 🥳"; hasBlackJack = true } else { - console.log("You're out of the game! 😭") + message = "You're out of the game! 😭"; isAlive = false } // 3. Log it out! +console.log(message); \ No newline at end of file diff --git a/3. Build a Blackjack game/11. Link to stylesheet/index.html b/3. Build a Blackjack game/11. Link to stylesheet/index.html index 2b676738..4a2e6cae 100644 --- a/3. Build a Blackjack game/11. Link to stylesheet/index.html +++ b/3. Build a Blackjack game/11. Link to stylesheet/index.html @@ -1,7 +1,10 @@ - + + + +

Blackjack

diff --git a/3. Build a Blackjack game/12. Add basic styling/index.css b/3. Build a Blackjack game/12. Add basic styling/index.css index 05185891..ec99838a 100644 --- a/3. Build a Blackjack game/12. Add basic styling/index.css +++ b/3. Build a Blackjack game/12. Add basic styling/index.css @@ -1,13 +1,21 @@ /* Complete the CSS styling according to the provided design */ body { + font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; + text-align: center; + font-weight: bold; + background-image: url("./images/table.png"); + background-size: cover; + color: white; + } h1 { color: goldenrod; + } #message-el { - + font-style: italic; } diff --git a/3. Build a Blackjack game/12. Add basic styling/index.html b/3. Build a Blackjack game/12. Add basic styling/index.html index 96b296f9..560973cf 100644 --- a/3. Build a Blackjack game/12. Add basic styling/index.html +++ b/3. Build a Blackjack game/12. Add basic styling/index.html @@ -9,4 +9,4 @@

Blackjack

Sum:

- \ No newline at end of file + diff --git a/3. Build a Blackjack game/13. Make the start button work/index.css b/3. Build a Blackjack game/13. Make the start button work/index.css index 463c27c8..1ec2560f 100644 --- a/3. Build a Blackjack game/13. Make the start button work/index.css +++ b/3. Build a Blackjack game/13. Make the start button work/index.css @@ -23,5 +23,12 @@ background - goldenrod */ button { - + color: #016f32; + background-color: goldenrod; + width: 150px; + padding-top: 5px; + padding-bottom: 5px; + font-weight: bold; + border: none; + border-radius: 2px; } \ No newline at end of file diff --git a/3. Build a Blackjack game/13. Make the start button work/index.html b/3. Build a Blackjack game/13. Make the start button work/index.html index 02d6bcbc..f5c7e70c 100644 --- a/3. Build a Blackjack game/13. Make the start button work/index.html +++ b/3. Build a Blackjack game/13. Make the start button work/index.html @@ -9,6 +9,7 @@

Blackjack

Sum:

+ \ No newline at end of file diff --git a/3. Build a Blackjack game/13. Make the start button work/index.js b/3. Build a Blackjack game/13. Make the start button work/index.js index ed9bbb49..9071601f 100644 --- a/3. Build a Blackjack game/13. Make the start button work/index.js +++ b/3. Build a Blackjack game/13. Make the start button work/index.js @@ -7,14 +7,15 @@ let message = "" // 2. Create a startGame() function. Move the conditional // below (line 11-20) inside the body of the function. - -if (sum <= 20) { - message = "Do you want to draw a new card? 🙂" -} else if (sum === 21) { - message = "Wohoo! You've got Blackjack! 🥳" - hasBlackJack = true -} else { - message = "You're out of the game! 😭" - isAlive = false -} -console.log(message) +function startGame() { + if (sum <= 20) { + message = "Do you want to draw a new card? 🙂" + } else if (sum === 21) { + message = "Wohoo! You've got Blackjack! 🥳" + hasBlackJack = true + } else { + message = "You're out of the game! 😭" + isAlive = false + } + console.log(message) +} \ No newline at end of file diff --git a/3. Build a Blackjack game/14. Display the message/index.html b/3. Build a Blackjack game/14. Display the message/index.html index 9d53d797..779d2481 100644 --- a/3. Build a Blackjack game/14. Display the message/index.html +++ b/3. Build a Blackjack game/14. Display the message/index.html @@ -10,4 +10,4 @@

Blackjack

- \ No newline at end of file + diff --git a/3. Build a Blackjack game/14. Display the message/index.js b/3. Build a Blackjack game/14. Display the message/index.js index 5e60181a..b0bbbfb8 100644 --- a/3. Build a Blackjack game/14. Display the message/index.js +++ b/3. Build a Blackjack game/14. Display the message/index.js @@ -1,22 +1,23 @@ let firstCard = 10 -let secondCard = 4 +let secondCard = 11 let sum = firstCard + secondCard let hasBlackJack = false let isAlive = true let message = "" // 1. Store the message-el paragraph in a variable called messageEl +let messageEl = document.querySelector("#message-el"); function startGame() { if (sum <= 20) { - message = "Do you want to draw a new card? 🙂" + message = "Do you want to draw a new card?" } else if (sum === 21) { - message = "Wohoo! You've got Blackjack! 🥳" + message = "You've got Blackjack!" hasBlackJack = true } else { - message = "You're out of the game! 😭" + message = "You're out of the game!" isAlive = false } // 2. Display the message in the messageEl using messageEl.textContent - console.log(message) + messageEl.textContent = message; } diff --git a/3. Build a Blackjack game/15. Display the sum/index.html b/3. Build a Blackjack game/15. Display the sum/index.html index f5514ea3..07405b85 100644 --- a/3. Build a Blackjack game/15. Display the sum/index.html +++ b/3. Build a Blackjack game/15. Display the sum/index.html @@ -7,8 +7,10 @@

Blackjack

Want to play a round?

Cards:

-

Sum:

+

Sum:

- \ No newline at end of file + + + diff --git a/3. Build a Blackjack game/15. Display the sum/index.js b/3. Build a Blackjack game/15. Display the sum/index.js index 6da8fc00..6d5de2dc 100644 --- a/3. Build a Blackjack game/15. Display the sum/index.js +++ b/3. Build a Blackjack game/15. Display the sum/index.js @@ -6,9 +6,12 @@ let isAlive = true let message = "" let messageEl = document.getElementById("message-el") // 2. Store the sum paragraph in a variable called sumEl +let sumEl = document.getElementById("sum-el"); +console.log(sumEl); function startGame() { // 3. Render the sum on the page using this format -> "Sum: 14" + sumEl.textContent = "Sum: " + sum; if (sum <= 20) { message = "Do you want to draw a new card?" } else if (sum === 21) { diff --git a/3. Build a Blackjack game/16. Display the cards/index.html b/3. Build a Blackjack game/16. Display the cards/index.html index f9593f06..c362eae5 100644 --- a/3. Build a Blackjack game/16. Display the cards/index.html +++ b/3. Build a Blackjack game/16. Display the cards/index.html @@ -6,7 +6,7 @@

Blackjack

Want to play a round?

-

Cards:

+

Cards:

Sum:

diff --git a/3. Build a Blackjack game/16. Display the cards/index.js b/3. Build a Blackjack game/16. Display the cards/index.js index 614ee50e..8922999c 100644 --- a/3. Build a Blackjack game/16. Display the cards/index.js +++ b/3. Build a Blackjack game/16. Display the cards/index.js @@ -7,9 +7,11 @@ let message = "" let messageEl = document.getElementById("message-el") let sumEl = document.getElementById("sum-el") // 2. Store the cards paragraph in a variable called cardsEl +let cardsEl = document.querySelector("#cards-el") function startGame() { // 3. Render the cars on the page using this format -> "Cards: 10 4" + cardsEl.textContent = "Cards: " + firstCard + " " + secondCard sumEl.textContent = "Sum: " + sum if (sum <= 20) { message = "Do you want to draw a new card?" diff --git a/3. Build a Blackjack game/17. New card button/index.css b/3. Build a Blackjack game/17. New card button/index.css index 94828496..17077b3b 100644 --- a/3. Build a Blackjack game/17. New card button/index.css +++ b/3. Build a Blackjack game/17. New card button/index.css @@ -26,4 +26,6 @@ button { font-weight: bold; border: none; border-radius: 2px; + margin-top: 2px; + margin-bottom: 2px; } \ No newline at end of file diff --git a/3. Build a Blackjack game/17. New card button/index.html b/3. Build a Blackjack game/17. New card button/index.html index 4ef52500..839c720d 100644 --- a/3. Build a Blackjack game/17. New card button/index.html +++ b/3. Build a Blackjack game/17. New card button/index.html @@ -9,6 +9,7 @@

Blackjack

Sum:

+ \ No newline at end of file diff --git a/3. Build a Blackjack game/17. New card button/index.js b/3. Build a Blackjack game/17. New card button/index.js index 40c8eba3..4ab00f75 100644 --- a/3. Build a Blackjack game/17. New card button/index.js +++ b/3. Build a Blackjack game/17. New card button/index.js @@ -24,3 +24,6 @@ function startGame() { } // 2. Create a function newCard() that logs out "Drawing a new card from the deck!" +function newCard () { + console.log("Drawing a new card from the deck!"); +} \ No newline at end of file diff --git a/3. Build a Blackjack game/18. Add to the sum when newCard is clicked/index.js b/3. Build a Blackjack game/18. Add to the sum when newCard is clicked/index.js index 96f220e1..c95e12ee 100644 --- a/3. Build a Blackjack game/18. Add to the sum when newCard is clicked/index.js +++ b/3. Build a Blackjack game/18. Add to the sum when newCard is clicked/index.js @@ -27,8 +27,9 @@ function startGame() { function newCard() { console.log("Drawing a new card from the deck!") // 1. Create a card variable, and hard code its value to a number (2-11) - + let drawnCard = 4 // 2. Add the new card to the sum variable - + sum += drawnCard // 3. Call startGame() + startGame(); } diff --git a/3. Build a Blackjack game/19. Rename the startGame function/index.js b/3. Build a Blackjack game/19. Rename the startGame function/index.js index 8efd421f..96d9e840 100644 --- a/3. Build a Blackjack game/19. Rename the startGame function/index.js +++ b/3. Build a Blackjack game/19. Rename the startGame function/index.js @@ -9,6 +9,10 @@ let sumEl = document.getElementById("sum-el") let cardsEl = document.getElementById("cards-el") function startGame() { + renderGame(); +} + +function renderGame() { cardsEl.textContent = "Cards: " + firstCard + " " + secondCard sumEl.textContent = "Sum: " + sum if (sum <= 20) { @@ -27,5 +31,5 @@ function startGame() { function newCard() { let card = 6 sum += card - startGame() + renderGame() } diff --git a/3. Build a Blackjack game/2. Add the firstCard, secondCard, and sum/index.js b/3. Build a Blackjack game/2. Add the firstCard, secondCard, and sum/index.js index 87b60dcb..fcec1e42 100644 --- a/3. Build a Blackjack game/2. Add the firstCard, secondCard, and sum/index.js +++ b/3. Build a Blackjack game/2. Add the firstCard, secondCard, and sum/index.js @@ -1,4 +1,10 @@ // 1. Create two variables, firstCard and secondCard. // Set their values to a random number between 2-11 +let firstCard = 7; +let secondCard = 5; + // 2. Create a variable, sum, and set it to the sum of the two cards + +let sum = firstCard + secondCard; +console.log(sum); diff --git a/3. Build a Blackjack game/20. Solving our cards problem with an array/index.js b/3. Build a Blackjack game/20. Solving our cards problem with an array/index.js index 4cf17f3c..5857e883 100644 --- a/3. Build a Blackjack game/20. Solving our cards problem with an array/index.js +++ b/3. Build a Blackjack game/20. Solving our cards problem with an array/index.js @@ -1,5 +1,6 @@ let firstCard = 10 let secondCard = 4 +let cards = [firstCard, secondCard] let sum = firstCard + secondCard let hasBlackJack = false let isAlive = true @@ -14,7 +15,7 @@ function startGame() { function renderGame() { // render out firstCard and secondCard - cardsEl.textContent = "Cards: " + firstCard + " " + secondCard + cardsEl.textContent = "Cards: " + cards[0] + " " + cards[1] // render out ALL the cards we have sumEl.textContent = "Sum: " + sum if (sum <= 20) { diff --git a/3. Build a Blackjack game/21. Intro to arrays/index.js b/3. Build a Blackjack game/21. Intro to arrays/index.js index 91e8cf0e..b7546941 100644 --- a/3. Build a Blackjack game/21. Intro to arrays/index.js +++ b/3. Build a Blackjack game/21. Intro to arrays/index.js @@ -9,3 +9,8 @@ let featuredPosts = [ // Create an array that lists your i.e. experience, education, licenses, skills or similar // The items of the array should be strings +let myExperience = [ + "Coding Bootcamp Certificate (Northwestern University)", + "M.A. in Research and Experimental Psychology (NYU)", + "B.A. in Psychology (Webster University)" +] \ No newline at end of file diff --git a/3. Build a Blackjack game/22. Array indexes/index.js b/3. Build a Blackjack game/22. Array indexes/index.js index 1ee7e954..5a928f88 100644 --- a/3. Build a Blackjack game/22. Array indexes/index.js +++ b/3. Build a Blackjack game/22. Array indexes/index.js @@ -11,5 +11,8 @@ let experience = ["CEO at Scrimba", "Frontend developer at Xeneta", "People coun // Make the following appear in the console: // Frontend developer at Xeneta +console.log(experience[1]) // People counter for Norstat -// CEO at Scrimba \ No newline at end of file +console.log(experience[2]) +// CEO at Scrimba +console.log(experience[0]) \ No newline at end of file diff --git a/3. Build a Blackjack game/23. Arrays with multiple data types/index.js b/3. Build a Blackjack game/23. Arrays with multiple data types/index.js index df3ec000..9396b342 100644 --- a/3. Build a Blackjack game/23. Arrays with multiple data types/index.js +++ b/3. Build a Blackjack game/23. Arrays with multiple data types/index.js @@ -1,4 +1,10 @@ // Array - ordered list of items - coposite / complex data type // Create an array that describes yourself. Use the three primitive data types you've learned -// It should contain your name (string), your age (number), and whether you like pizza (boolean) \ No newline at end of file +// It should contain your name (string), your age (number), and whether you like pizza (boolean) + +let user = ["Veronika", 31, true]; + +for (let i = 0; i < user.length; i++) { + console.log(user[i]) +} diff --git a/3. Build a Blackjack game/24. Adding and removing items from arrays/index.js b/3. Build a Blackjack game/24. Adding and removing items from arrays/index.js index f4dfa41d..873be219 100644 --- a/3. Build a Blackjack game/24. Adding and removing items from arrays/index.js +++ b/3. Build a Blackjack game/24. Adding and removing items from arrays/index.js @@ -1,6 +1,6 @@ let cards = [7, 4] cards.push(6) -//console.log(cards) +// console.log(cards) // Push the newMessage to the messages array, and then log out the array @@ -12,5 +12,11 @@ let messages = [ let newMessage = "Same here!" +messages.push(newMessage) +console.log(messages) + +messages.pop() + +console.log(messages) diff --git a/3. Build a Blackjack game/25. Creating the cards array/index.js b/3. Build a Blackjack game/25. Creating the cards array/index.js index 67e05cbb..ae8d67e9 100644 --- a/3. Build a Blackjack game/25. Creating the cards array/index.js +++ b/3. Build a Blackjack game/25. Creating the cards array/index.js @@ -1,6 +1,7 @@ let firstCard = 10 let secondCard = 4 // 1. Create a new array - cards - that contains firstCard and secondCard +let cards = [firstCard, secondCard] let sum = firstCard + secondCard let hasBlackJack = false let isAlive = true @@ -15,7 +16,7 @@ function startGame() { function renderGame() { // 2. Refer to the cards array when rendering out the cards - cardsEl.textContent = "Cards: " + firstCard + " " + secondCard + cardsEl.textContent = "Cards: " + cards[0] + " " + cards[1] sumEl.textContent = "Sum: " + sum if (sum <= 20) { message = "Do you want to draw a new card?" diff --git a/3. Build a Blackjack game/26. Push a new card to the array/index.js b/3. Build a Blackjack game/26. Push a new card to the array/index.js index 830f34b2..c77ed911 100644 --- a/3. Build a Blackjack game/26. Push a new card to the array/index.js +++ b/3. Build a Blackjack game/26. Push a new card to the array/index.js @@ -33,5 +33,7 @@ function newCard() { let card = 6 sum += card // Push the card to the cards array + cards.push(card) + console.log(cards) renderGame() } diff --git a/3. Build a Blackjack game/27. Counting in JavaScript/index.js b/3. Build a Blackjack game/27. Counting in JavaScript/index.js index 323d7e34..3e4e5177 100644 --- a/3. Build a Blackjack game/27. Counting in JavaScript/index.js +++ b/3. Build a Blackjack game/27. Counting in JavaScript/index.js @@ -7,7 +7,7 @@ // What's the STEP SIZE we should use? // START FINISH STEP SIZE -for ( let count = 1; count < 11; count += 1 ) { +for ( let count = 10; count < 21; count += 1 ) { console.log(count) diff --git a/3. Build a Blackjack game/28. Write your first loop/index.js b/3. Build a Blackjack game/28. Write your first loop/index.js index d6ab9134..733efa33 100644 --- a/3. Build a Blackjack game/28. Write your first loop/index.js +++ b/3. Build a Blackjack game/28. Write your first loop/index.js @@ -2,3 +2,7 @@ // Create a for loop that counts from 10 to 100 in steps of 10 // Use console.log to log out the numbers + +for (let i = 10; i < 101; i += 10) { + console.log(i) +} diff --git a/3. Build a Blackjack game/29. For loops and arrays/index.js b/3. Build a Blackjack game/29. For loops and arrays/index.js index 667672a4..560dbb5b 100644 --- a/3. Build a Blackjack game/29. For loops and arrays/index.js +++ b/3. Build a Blackjack game/29. For loops and arrays/index.js @@ -3,7 +3,11 @@ let messages = [ "I'm great, thank you! How about you?", "All good. Been working on my portfolio lately.", "Same here!", - "Great to hear" + "Great to hear", + "How's the job search going?", + "Great, I have two interviews scheduled new week", + "Amazing, I just had my first interview. It went well. They invited me to second round.", + "That's awesome!" ] // DRY - Don't repeat yourself @@ -12,5 +16,7 @@ let messages = [ // console.log(messages[2]) // console.log(messages[3]) - +for (let i = 0; i < messages.length; i++) { + console.log(messages[i]) +} diff --git a/3. Build a Blackjack game/3. If...else conditionals/index.js b/3. Build a Blackjack game/3. If...else conditionals/index.js index ec802b41..7f3e283c 100644 --- a/3. Build a Blackjack game/3. If...else conditionals/index.js +++ b/3. Build a Blackjack game/3. If...else conditionals/index.js @@ -1,4 +1,11 @@ -let firstCard = 6 -let secondCard = 9 -let sum = firstCard + secondCard +let firstCard = 10 +let secondCard = 7 +let sum = firstCard + secondCard + 8 // 26 +if (sum < 21) { + console.log("Do you want to draw a new card?"); +} else if (sum === 21) { + console.log("Woohoo! You've got blackjack!"); +} else { + console.log("You're out of the game!"); +} \ No newline at end of file diff --git a/3. Build a Blackjack game/30. Write you first array-based for loop/index.js b/3. Build a Blackjack game/30. Write you first array-based for loop/index.js index c650b223..f350d361 100644 --- a/3. Build a Blackjack game/30. Write you first array-based for loop/index.js +++ b/3. Build a Blackjack game/30. Write you first array-based for loop/index.js @@ -1,6 +1,8 @@ -let cards = [7, 3, 9] +let cards = [7, 3, 9, 2] // Create a for loop that logs out all the cards in the array // Use cards.length to specify how long the loop should run - +for (let i = 0; i < cards.length; i++) { + console.log(cards[i]) +} diff --git a/3. Build a Blackjack game/31. For loops, arrays, and DOM/index.js b/3. Build a Blackjack game/31. For loops, arrays, and DOM/index.js index 9f6ff24d..d599df85 100644 --- a/3. Build a Blackjack game/31. For loops, arrays, and DOM/index.js +++ b/3. Build a Blackjack game/31. For loops, arrays, and DOM/index.js @@ -1,5 +1,7 @@ -let sentence = ["Hello ", "my ", "name ", "is ", "Per"] +let sentence = ["Hello", "my", "name", "is", "Per"] let greetingEl = document.getElementById("greeting-el") // Render the sentence in the greetingEl paragraph using a for loop and .textContent - +for (let i = 0; i < sentence.length; i++) { + greetingEl.textContent += sentence[i] + " " +} \ No newline at end of file diff --git a/3. Build a Blackjack game/32. Use a loop to render cards/index.html b/3. Build a Blackjack game/32. Use a loop to render cards/index.html index 86fc8409..a27e45ce 100644 --- a/3. Build a Blackjack game/32. Use a loop to render cards/index.html +++ b/3. Build a Blackjack game/32. Use a loop to render cards/index.html @@ -11,4 +11,6 @@

Blackjack

- \ No newline at end of file + + + \ No newline at end of file diff --git a/3. Build a Blackjack game/32. Use a loop to render cards/index.js b/3. Build a Blackjack game/32. Use a loop to render cards/index.js index fa473ab9..cfae5ef5 100644 --- a/3. Build a Blackjack game/32. Use a loop to render cards/index.js +++ b/3. Build a Blackjack game/32. Use a loop to render cards/index.js @@ -14,9 +14,12 @@ function startGame() { } function renderGame() { - cardsEl.textContent = "Cards: " + cards[0] + " " + cards[1] + cardsEl.textContent = "Cards: " // Create a for loop that renders out all the cards instead of just two - + for (let i = 0; i < cards.length; i++) { + cardsEl.textContent += cards[i] + " " + } + sumEl.textContent = "Sum: " + sum if (sum <= 20) { message = "Do you want to draw a new card?" diff --git a/3. Build a Blackjack game/33. How can we avoid to hard-code card values?/index.js b/3. Build a Blackjack game/33. How can we avoid to hard-code card values?/index.js index 16a5856b..764f92a0 100644 --- a/3. Build a Blackjack game/33. How can we avoid to hard-code card values?/index.js +++ b/3. Build a Blackjack game/33. How can we avoid to hard-code card values?/index.js @@ -1,5 +1,5 @@ -let firstCard = 10 -let secondCard = 4 +let firstCard = getRandomCard() +let secondCard = getRandomCard() let cards = [firstCard, secondCard] let sum = firstCard + secondCard let hasBlackJack = false @@ -37,7 +37,7 @@ function renderGame() { function newCard() { - let card = 6 + let card = getRandomCard() sum += card cards.push(card) console.log(cards) diff --git a/3. Build a Blackjack game/34. Returning values in functions/index.js b/3. Build a Blackjack game/34. Returning values in functions/index.js index fc725f25..a6aa2fa0 100644 --- a/3. Build a Blackjack game/34. Returning values in functions/index.js +++ b/3. Build a Blackjack game/34. Returning values in functions/index.js @@ -12,12 +12,33 @@ function getFastestRaceTime() { } } -// let fastestRace = getFastestRaceTime() -// console.log(fastestRace) +let fastestRace = getFastestRaceTime() +console.log(fastestRace) + // Write a function that returns the total race time // Call/invoke the function and store the returned value in a new variable // Finally, log the variable out +function getTotalRaceTime() { + return player1Time + player2Time +} + +let totalRaceTime = getTotalRaceTime() +console.log(totalRaceTime) + +// function getTotalRaceTime() { +// if (player1Time > player2Time) { +// return player1Time +// } else if (player2Time > player1Time) { +// return player2Time +// } else { +// return player1Time +// } +// } + +// let totalRaceTime = getTotalRaceTime() +// console.log(totalRaceTime) + diff --git a/3. Build a Blackjack game/35. Use a function to set the card values/index.js b/3. Build a Blackjack game/35. Use a function to set the card values/index.js index 453129ae..46af44ff 100644 --- a/3. Build a Blackjack game/35. Use a function to set the card values/index.js +++ b/3. Build a Blackjack game/35. Use a function to set the card values/index.js @@ -1,6 +1,6 @@ // 2. Use getRandomCard() to set the values of firstCard and secondCard -let firstCard = 10 -let secondCard = 4 +let firstCard = getRandomCard() +let secondCard = getRandomCard() let cards = [firstCard, secondCard] let sum = firstCard + secondCard let hasBlackJack = false @@ -11,8 +11,9 @@ let sumEl = document.getElementById("sum-el") let cardsEl = document.getElementById("cards-el") // 1. Create a function, getRandomCard(), that always returns the number 5 - - +function getRandomCard() { + return 5 +} function startGame() { renderGame() @@ -40,7 +41,7 @@ function renderGame() { function newCard() { // 3. Use the getRandomCard() to set the value of card - let card = 6 + let card = getRandomCard() sum += card cards.push(card) console.log(cards) diff --git a/3. Build a Blackjack game/36. Generating random numbers with Math.random()/index.js b/3. Build a Blackjack game/36. Generating random numbers with Math.random()/index.js index c59ac526..7a230236 100644 --- a/3. Build a Blackjack game/36. Generating random numbers with Math.random()/index.js +++ b/3. Build a Blackjack game/36. Generating random numbers with Math.random()/index.js @@ -7,6 +7,6 @@ console.log(randomNumber) What does Math.random() do? -Your answer: +Your answer: generates random numbers in the range of 0.000 to 0.999 */ \ No newline at end of file diff --git a/3. Build a Blackjack game/37. Math.random() * 6/index.js b/3. Build a Blackjack game/37. Math.random() * 6/index.js index d4821db3..975bf9f4 100644 --- a/3. Build a Blackjack game/37. Math.random() * 6/index.js +++ b/3. Build a Blackjack game/37. Math.random() * 6/index.js @@ -1,4 +1,4 @@ -let randomNumber = Math.random() +let randomNumber = Math.random() * 6 console.log(randomNumber) @@ -7,7 +7,7 @@ console.log(randomNumber) In which range will our randomNumber be now? -From: -To: +From: 0 +To: 5.999 */ \ No newline at end of file diff --git a/3. Build a Blackjack game/38. Flooring the number with Math.floor()/index.js b/3. Build a Blackjack game/38. Flooring the number with Math.floor()/index.js index c3374888..f549253b 100644 --- a/3. Build a Blackjack game/38. Flooring the number with Math.floor()/index.js +++ b/3. Build a Blackjack game/38. Flooring the number with Math.floor()/index.js @@ -1,6 +1,6 @@ // let randomNumber = Math.random() * 6 -let flooredNumber = Math.floor(3.45632) +let flooredNumber = Math.floor(3.632) console.log(flooredNumber) @@ -9,6 +9,6 @@ console.log(flooredNumber) What does Math.floor() do to positive numbers? -Your answer: +Your answer: removes the decimals */ \ No newline at end of file diff --git a/3. Build a Blackjack game/39. Using Math.random() and Math.floor() to create a dice/index.js b/3. Build a Blackjack game/39. Using Math.random() and Math.floor() to create a dice/index.js index cd7ae39e..2477f0b2 100644 --- a/3. Build a Blackjack game/39. Using Math.random() and Math.floor() to create a dice/index.js +++ b/3. Build a Blackjack game/39. Using Math.random() and Math.floor() to create a dice/index.js @@ -1,11 +1,11 @@ -let randomNumber = Math.random() * 6 +let randomNumber = Math.floor(Math.random() * 6) console.log(randomNumber) /* Write down all the possible values randomNumber can hold now! - +Answer: 0 to 5 diff --git a/3. Build a Blackjack game/4. Your first if...else statement/index.js b/3. Build a Blackjack game/4. Your first if...else statement/index.js index e1c5b6d8..76de07d8 100644 --- a/3. Build a Blackjack game/4. Your first if...else statement/index.js +++ b/3. Build a Blackjack game/4. Your first if...else statement/index.js @@ -6,3 +6,8 @@ let age = 22 // if less than 21 -> "You can not enter the club!" // else -> "Welcome!" +if (age <= 20) { + console.log("You can't enter the club."); +} else { + console.log("Welcome to the club!"); +} \ No newline at end of file diff --git a/3. Build a Blackjack game/40. Completing our dice function/index.js b/3. Build a Blackjack game/40. Completing our dice function/index.js index 404bbd99..cedd5080 100644 --- a/3. Build a Blackjack game/40. Completing our dice function/index.js +++ b/3. Build a Blackjack game/40. Completing our dice function/index.js @@ -1,5 +1,7 @@ // Try to modify the expression so that we get a range from 1 to 6 -let randomNumber = Math.floor( Math.random() * 6 ) - -console.log(randomNumber) +function rollDice() { + let randomNumber = Math.floor( Math.random() * 6 ) + 1 + return randomNumber +} +console.log(rollDice()) \ No newline at end of file diff --git a/3. Build a Blackjack game/41. Make getRandomCard() work/index.js b/3. Build a Blackjack game/41. Make getRandomCard() work/index.js index 7ca78e13..2ad88d28 100644 --- a/3. Build a Blackjack game/41. Make getRandomCard() work/index.js +++ b/3. Build a Blackjack game/41. Make getRandomCard() work/index.js @@ -11,7 +11,7 @@ let cardsEl = document.getElementById("cards-el") // Make this function return a random number between 1 and 13 function getRandomCard() { - return 5 + return Math.floor(Math.random()*13) + 1 } function startGame() { diff --git a/3. Build a Blackjack game/42. Complete getRandomNumber function/index.js b/3. Build a Blackjack game/42. Complete getRandomNumber function/index.js index bb615109..333cb0ba 100644 --- a/3. Build a Blackjack game/42. Complete getRandomNumber function/index.js +++ b/3. Build a Blackjack game/42. Complete getRandomNumber function/index.js @@ -11,9 +11,14 @@ let cardsEl = document.getElementById("cards-el") function getRandomCard() { - // if 1 -> return 11 - // if 11-13 -> return 10 - return Math.floor( Math.random()*13 ) + 1 + let randomCard = Math.floor( Math.random()*13 ) + 1 + if (randomCard === 1) { + return 11 + } else if (randomCard > 10) { + return 10 + } else { + return randomCard + } } function startGame() { diff --git a/3. Build a Blackjack game/43. Assign values in the startGame function/index.js b/3. Build a Blackjack game/43. Assign values in the startGame function/index.js index 48d61a5d..889052f1 100644 --- a/3. Build a Blackjack game/43. Assign values in the startGame function/index.js +++ b/3. Build a Blackjack game/43. Assign values in the startGame function/index.js @@ -1,9 +1,7 @@ -let firstCard = getRandomCard() -let secondCard = getRandomCard() -let cards = [firstCard, secondCard] -let sum = firstCard + secondCard +let cards = [ ] +let sum = 0 let hasBlackJack = false -let isAlive = true +let isAlive = false let message = "" let messageEl = document.getElementById("message-el") let sumEl = document.getElementById("sum-el") @@ -23,8 +21,11 @@ function getRandomCard() { } function startGame() { - // Generate two random numbes - // Re-assign the cards and sum variables so that the game can start + isAlive = true + let firstCard = getRandomCard() + let secondCard = getRandomCard() + cards = [firstCard, secondCard] + sum = firstCard + secondCard renderGame() } diff --git a/3. Build a Blackjack game/45. The logical AND operator/index.js b/3. Build a Blackjack game/45. The logical AND operator/index.js index 9d978de8..b686aef7 100644 --- a/3. Build a Blackjack game/45. The logical AND operator/index.js +++ b/3. Build a Blackjack game/45. The logical AND operator/index.js @@ -1,10 +1,8 @@ -let hasCompletedCourse = false +let hasCompletedCourse = true let givesCertificate = true -if (hasCompletedCourse === true) { - if (givesCertificate === true) { - generateCertificate() - } +if (hasCompletedCourse && givesCertificate === true) { + generateCertificate() } function generateCertificate() { diff --git a/3. Build a Blackjack game/46. Write your first logical operator/index.js b/3. Build a Blackjack game/46. Write your first logical operator/index.js index 1c7114b3..6276d5da 100644 --- a/3. Build a Blackjack game/46. Write your first logical operator/index.js +++ b/3. Build a Blackjack game/46. Write your first logical operator/index.js @@ -1,9 +1,13 @@ -let hasSolvedChallenge = false +let hasSolvedChallenge = true let hasHintsLeft = false // Create an if statement that checks that both variables are false. // If so, run the showSolution() function +if (hasSolvedChallenge === false && hasHintsLeft === false) { + showSolution() +} + function showSolution() { console.log("Showing the solution....") } diff --git a/3. Build a Blackjack game/47. The logical OR operator/index.js b/3. Build a Blackjack game/47. The logical OR operator/index.js index 7412187b..e104f116 100644 --- a/3. Build a Blackjack game/47. The logical OR operator/index.js +++ b/3. Build a Blackjack game/47. The logical OR operator/index.js @@ -1,6 +1,13 @@ // Create two boolean variables, likesDocumentaries and likesStartups // Use an OR statement (||) to call recommendMovie() if either of those variables are true +let likesDocumentaries = true +let likesStartups = false + +if (likesDocumentaries === true || likesStartups === true) { + recommendMovie() +} + function recommendMovie() { console.log("Hey, check out this new film we think you will like!") } diff --git a/3. Build a Blackjack game/48. Only trigger newCard() if you're allowed to/index.js b/3. Build a Blackjack game/48. Only trigger newCard() if you're allowed to/index.js index adf11f0f..cda87499 100644 --- a/3. Build a Blackjack game/48. Only trigger newCard() if you're allowed to/index.js +++ b/3. Build a Blackjack game/48. Only trigger newCard() if you're allowed to/index.js @@ -48,9 +48,10 @@ function renderGame() { function newCard() { - // Only allow the player to get a new card if she IS alive and does NOT have Blackjack - let card = getRandomCard() - sum += card - cards.push(card) - renderGame() + if (isAlive === true && hasBlackJack === false) { + let card = getRandomCard() + sum += card + cards.push(card) + renderGame() + } } diff --git a/3. Build a Blackjack game/49. Object sneak peek/index.js b/3. Build a Blackjack game/49. Object sneak peek/index.js index fa7385c2..1b56a412 100644 --- a/3. Build a Blackjack game/49. Object sneak peek/index.js +++ b/3. Build a Blackjack game/49. Object sneak peek/index.js @@ -7,14 +7,20 @@ let messageEl = document.getElementById("message-el") let sumEl = document.getElementById("sum-el") let cardsEl = document.getElementById("cards-el") -let player = { - name: "Per", - chips: 145 -} +// let player = { +// name: "Veronika", +// chips: 145 +// } +let playerName = "Veronika" +let playerChips = 145 let playerEl = document.getElementById("player-el") -playerEl.textContent = player.name + ": $" + player.chips +playerEl.textContent = playerName + ": $" + playerChips + + +// let playerEl = document.getElementById("player-el") +// playerEl.textContent = player.name + ": $" + player.chips function getRandomCard() { let randomNumber = Math.floor( Math.random()*13 ) + 1 diff --git a/3. Build a Blackjack game/5. if:else...if:else statement/index.js b/3. Build a Blackjack game/5. if:else...if:else statement/index.js index b856709e..f67d347b 100644 --- a/3. Build a Blackjack game/5. if:else...if:else statement/index.js +++ b/3. Build a Blackjack game/5. if:else...if:else statement/index.js @@ -4,4 +4,12 @@ let age = 100 // if less than 100 -> "Not elegible" // else if exactly 100 -> "Here is your birthday card from the King!" -// else -> "Not elegible, you have already gotten one" \ No newline at end of file +// else -> "Not elegible, you have already gotten one" + +if (age < 100) { + console.log("Not eligible."); +} else if (age === 100) { + console.log("Here is your birthday card from the King!"); +} else { + console.log("Not elegible, you've already gotten one."); +} \ No newline at end of file diff --git a/3. Build a Blackjack game/50. Intro to objects/index.js b/3. Build a Blackjack game/50. Intro to objects/index.js index 0870bae7..f37e42eb 100644 --- a/3. Build a Blackjack game/50. Intro to objects/index.js +++ b/3. Build a Blackjack game/50. Intro to objects/index.js @@ -12,6 +12,6 @@ let course = { } -console.log( course.tags ) +console.log(course.tags) diff --git a/3. Build a Blackjack game/51. Create your first object/index.js b/3. Build a Blackjack game/51. Create your first object/index.js index 7d5c3fe6..8953c78e 100644 --- a/3. Build a Blackjack game/51. Create your first object/index.js +++ b/3. Build a Blackjack game/51. Create your first object/index.js @@ -3,3 +3,12 @@ // Log out at least two of the keys using the dot notation +let castleListing = { + isFreeNow: true, + floors: 3, + location: "France", + features: ["garden", "fountain"] +} + +console.log(castleListing.features) +console.log(castleListing.floors) \ No newline at end of file diff --git a/3. Build a Blackjack game/52. Use an object to store player data/index.html b/3. Build a Blackjack game/52. Use an object to store player data/index.html index 3b8f89de..f31075b9 100644 --- a/3. Build a Blackjack game/52. Use an object to store player data/index.html +++ b/3. Build a Blackjack game/52. Use an object to store player data/index.html @@ -9,6 +9,7 @@

Blackjack

Sum:

+

diff --git a/3. Build a Blackjack game/52. Use an object to store player data/index.js b/3. Build a Blackjack game/52. Use an object to store player data/index.js index aaa0bcf6..8e3abf21 100644 --- a/3. Build a Blackjack game/52. Use an object to store player data/index.js +++ b/3. Build a Blackjack game/52. Use an object to store player data/index.js @@ -1,4 +1,9 @@ // 2. Create the player object. Give it two keys, name and chips, and set their values +let player = { + name: "Veronika", + chips: 200 +} + let cards = [] let sum = 0 let hasBlackJack = false @@ -8,8 +13,10 @@ let messageEl = document.getElementById("message-el") let sumEl = document.getElementById("sum-el") let cardsEl = document.getElementById("cards-el") // 3. Grab ahold of the player-el paragraph and store it in a variable called playerEl +let playerEl = document.getElementById("player-el") // 4. Render the player's name and chips in playerEl +playerEl.textContent = player.name + ": $" + player.chips function getRandomCard() { let randomNumber = Math.floor( Math.random()*13 ) + 1 diff --git a/3. Build a Blackjack game/53. Methods on object/index.js b/3. Build a Blackjack game/53. Methods on object/index.js index de2df3b1..0cae5088 100644 --- a/3. Build a Blackjack game/53. Methods on object/index.js +++ b/3. Build a Blackjack game/53. Methods on object/index.js @@ -1,8 +1,13 @@ let player = { name: "Per", chips: 200, + sayHello: function(){ + console.log("Hello!") + } } +player.sayHello() + let cards = [] let sum = 0 let hasBlackJack = false diff --git a/3. Build a Blackjack game/6. The if...else statement for our game/index.js b/3. Build a Blackjack game/6. The if...else statement for our game/index.js index 558a286f..b27122ed 100644 --- a/3. Build a Blackjack game/6. The if...else statement for our game/index.js +++ b/3. Build a Blackjack game/6. The if...else statement for our game/index.js @@ -8,3 +8,11 @@ let sum = firstCard + secondCard // else if exactly 21 -> "Wohoo! You've got Blackjack! 🥳" // else -> "You're out of the game! 😭" + +if (sum <= 20) { + console.log("Do you want to draw a new card? 🙂") +} else if (sum === 21) { + console.log("Wohoo! You've got Blackjack! 🥳") +} else { + console.log("You're out of the game! 😭"); +} \ No newline at end of file diff --git a/3. Build a Blackjack game/7. Add the hasBlackJack variable/index.js b/3. Build a Blackjack game/7. Add the hasBlackJack variable/index.js index 95b1599e..c65f7870 100644 --- a/3. Build a Blackjack game/7. Add the hasBlackJack variable/index.js +++ b/3. Build a Blackjack game/7. Add the hasBlackJack variable/index.js @@ -1,13 +1,16 @@ let firstCard = 10 let secondCard = 11 let sum = firstCard + secondCard +let hasBlackJack = false; if (sum <= 20) { console.log("Do you want to draw a new card? 🙂") } else if (sum === 21) { console.log("Wohoo! You've got Blackjack! 🥳") + hasBlackJack = true; } else { console.log("You're out of the game! 😭") } // CASH OUT! +console.log(hasBlackJack) \ No newline at end of file diff --git a/3. Build a Blackjack game/8. Add the isAlive variable/index.js b/3. Build a Blackjack game/8. Add the isAlive variable/index.js index cf5067c4..9c79052b 100644 --- a/3. Build a Blackjack game/8. Add the isAlive variable/index.js +++ b/3. Build a Blackjack game/8. Add the isAlive variable/index.js @@ -1,8 +1,9 @@ let firstCard = 10 let secondCard = 11 -let sum = firstCard + secondCard +let sum = firstCard + secondCard + 6 let hasBlackJack = false // 1. Create a variable called isAlive and assign it to true +isAlive = true; // 2. Flip its value to false in the appropriate code block if (sum <= 20) { @@ -12,6 +13,8 @@ if (sum <= 20) { hasBlackJack = true } else { console.log("You're out of the game! 😭") + isAlive = false; } // 3. Log it out to check that you're doing it right +console.log(isAlive); \ No newline at end of file diff --git a/3. Build a Blackjack game/9. Let's practice boolean conditions/index.js b/3. Build a Blackjack game/9. Let's practice boolean conditions/index.js index ddbf5fd6..1cfbb188 100644 --- a/3. Build a Blackjack game/9. Let's practice boolean conditions/index.js +++ b/3. Build a Blackjack game/9. Let's practice boolean conditions/index.js @@ -1,10 +1,10 @@ -console.log(4 === 3) // -console.log(5 > 2) // -console.log(12 > 12) // -console.log(3 < 0) // -console.log(3 >= 3) // -console.log(11 <= 11) // -console.log(3 <= 2) // +console.log(4 === 3) // false +console.log(5 > 2) // true +console.log(12 > 12) // false +console.log(3 < 0) // false +console.log(3 >= 3) // true +console.log(11 <= 11) // true +console.log(3 <= 2) // false // let firstCard = 10 // let secondCard = 11 diff --git a/4. Practice time - part 2/1. Objects and functions/index.js b/4. Practice time - part 2/1. Objects and functions/index.js index ce48ca74..ffa1d38a 100644 --- a/4. Practice time - part 2/1. Objects and functions/index.js +++ b/4. Practice time - part 2/1. Objects and functions/index.js @@ -1,8 +1,20 @@ // Create a person object that contains three keys: name, age, and county. -// Use yourself as an example to set the values for name, age, and country + +let person = { + name: "Veronika", + age: 31, + country: "US" +} + // Create a function, logData(), that uses the person object to create a // string in the following format: // "Per is 35 years old and lives in Norway" -// Call the logData() function to verify that it works \ No newline at end of file +function logData() { + console.log(person.name + " is " + person.age + " years old and lives in " + person.country) +} + +// Call the logData() function to verify that it works + +logData(); \ No newline at end of file diff --git a/4. Practice time - part 2/2. if else/index.js b/4. Practice time - part 2/2. if else/index.js index 7eabce28..c5b40d39 100644 --- a/4. Practice time - part 2/2. if else/index.js +++ b/4. Practice time - part 2/2. if else/index.js @@ -1,4 +1,4 @@ -let age = 15 +let age = 45 // less than 6 years old -> free // 6 to 17 years old -> child discount @@ -7,4 +7,16 @@ let age = 15 // over 66 years old -> senior citizen discount // Create a conditional statement (if/else/else if) that logs out the discount -// the passenger will get based upon the value of the age variable \ No newline at end of file +// the passenger will get based upon the value of the age variable + +if (age < 6) { + console.log("Free") +} else if (age < 18){ + console.log("Child Discount") +} else if (age < 27) { + console.log("Student Discount") +} else if (age < 67) { + console.log("Full Price") +} else { + console.log("Senior Citizen Discount") +} diff --git a/4. Practice time - part 2/3. Loops and arrays/index.js b/4. Practice time - part 2/3. Loops and arrays/index.js index 8ace5085..64cacfcb 100644 --- a/4. Practice time - part 2/3. Loops and arrays/index.js +++ b/4. Practice time - part 2/3. Loops and arrays/index.js @@ -9,3 +9,9 @@ The 5 largest countries in the world: - Indinesia - Pakistan */ + +console.log("The 5 largest countries in the world:") +for (let i = 0; i < largeCountries.length; i++) { + console.log("- " + largeCountries[i]) +} + diff --git a/4. Practice time - part 2/4. push, pop, unshift, shift challenge/index.js b/4. Practice time - part 2/4. push, pop, unshift, shift challenge/index.js index fa50a31a..e3424ecb 100644 --- a/4. Practice time - part 2/4. push, pop, unshift, shift challenge/index.js +++ b/4. Practice time - part 2/4. push, pop, unshift, shift challenge/index.js @@ -5,3 +5,11 @@ let largeCountries = ["Tuvalu","India","USA","Indonesia","Monaco"] // Use push() & pop() and their counterparts unshift() & shift() // Google how to use unshift() and shift() +largeCountries.pop() +largeCountries.push("Pakistan") +largeCountries.shift() +largeCountries.unshift("China") + +console.log(largeCountries) + + diff --git a/4. Practice time - part 2/5. Logical operators/index.js b/4. Practice time - part 2/5. Logical operators/index.js index eb0d1930..0b72ece5 100644 --- a/4. Practice time - part 2/5. Logical operators/index.js +++ b/4. Practice time - part 2/5. Logical operators/index.js @@ -1,8 +1,10 @@ -let dayOfMonth = 13 +let dayOfMonth = 15 let weekday = "Friday" // If it is Friday the 13th, log out this spooky face: 😱 // Use the logical "AND operator" -> && - +if (dayOfMonth === 13 && weekday === "Friday") { + console.log("Scary!😱") +} diff --git a/4. Practice time - part 2/6. Rock papers scissors/index.js b/4. Practice time - part 2/6. Rock papers scissors/index.js index dc4958f6..97fdec1b 100644 --- a/4. Practice time - part 2/6. Rock papers scissors/index.js +++ b/4. Practice time - part 2/6. Rock papers scissors/index.js @@ -2,4 +2,9 @@ let hands = ["rock", "paper", "scissor"] // Create a function that returns a random item from the array +function randomRPS() { + let result = hands[Math.floor(Math.random() * 3)] + return result +} +console.log(randomRPS()) diff --git a/4. Practice time - part 2/7. Sorting fruits/index.js b/4. Practice time - part 2/7. Sorting fruits/index.js index 37ac9124..e7f9773a 100644 --- a/4. Practice time - part 2/7. Sorting fruits/index.js +++ b/4. Practice time - part 2/7. Sorting fruits/index.js @@ -1,4 +1,4 @@ -let fruit = ["🍎", "🍊", "🍎", "🍎", "🍊"] +let fruit = ["apple", "orange", "apple", "apple", "orange"] let appleShelf = document.getElementById("apple-shelf") let orangeShelf = document.getElementById("orange-shelf") @@ -6,3 +6,19 @@ let orangeShelf = document.getElementById("orange-shelf") // and the oranges onto the orangeShelf. Use a for loop, // a conditional statement, and the textContent property. +function sortFruit() { + + for (i = 0; i < fruit.length; i++) { + if (fruit[i] === "apple") { + appleShelf.textContent += fruit[i] + " " + console.log(appleShelf.textContent) + } else if (fruit[i] === "orange") { + orangeShelf.textContent += fruit[i] + " " + console.log(orangeShelf.textContent) + } + } +} + +sortFruit() + +// video paused on 4:33:57 \ No newline at end of file