GithubHelp home page GithubHelp logo

javascript-course's People

Contributors

supersimpledev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javascript-course's Issues

SyntaxError

I couldn't understand this error //// Uncaught SyntaxError: "undefined" is not valid JSON
at JSON.parse ()
at 10-rock-paper-scissor copy.html:43:27 ////

let scores = JSON.parse(localStorage.getItem('scores')) || {
wins:0,
losses:0,
ties:0
};
.
.
.
.
localStorage.setItem('scores', JSON.stringify(scores));

Lesson 14

Please does anyone have a comprehensive solution to the problem in lesson 14, I noticed that the cart disappears when I added local storage.

Here is the problem I am encountering:
Uncaught TypeError: Cannot read properties of undefined (reading 'id')
at checkout.js:20:48
at Array.forEach ()
at checkout.js:7:6Understand this error

Here is my code for checkout.js:
import {cart, removeFromCart} from '../data/cart.js';
import {products} from '../data/products.js';
import {formatCurrency} from './utils/money.js';

let cartSummaryHTML = '';

cart.forEach((cartItem) => {
const productId = cartItem.productId;

let matchingProduct;

products.forEach((product) => {
if (product.id === productId) {
matchingProduct = product;
}
});

cartSummaryHTML += `



Delivery date: Tuesday, June 21

  <div class="cart-item-details-grid">
    <img class="product-image"
      src="${matchingProduct.image}">

    <div class="cart-item-details">
      <div class="product-name">
        ${matchingProduct.name}
      </div>
      <div class="product-price">
        $${formatCurrency(matchingProduct.priceCents)}
      </div>
      <div class="product-quantity">
        <span>
          Quantity: <span class="quantity-label">${cartItem.quantity}</span>
        </span>
        <span class="update-quantity-link link-primary">
          Update
        </span>
        <span class="delete-quantity-link link-primary js-delete-link" data-product-id="${matchingProduct.id}">
          Delete
        </span>
      </div>
    </div>

    <div class="delivery-options">
      <div class="delivery-options-title">
        Choose a delivery option:
      </div>
      <div class="delivery-option">
        <input type="radio" checked
          class="delivery-option-input"
          name="delivery-option-${matchingProduct.id}">
        <div>
          <div class="delivery-option-date">
            Tuesday, June 21
          </div>
          <div class="delivery-option-price">
            FREE Shipping
          </div>
        </div>
      </div>
      <div class="delivery-option">
        <input type="radio"
          class="delivery-option-input"
          name="delivery-option-${matchingProduct.id}">
        <div>
          <div class="delivery-option-date">
            Wednesday, June 15
          </div>
          <div class="delivery-option-price">
            $4.99 - Shipping
          </div>
        </div>
      </div>
      <div class="delivery-option">
        <input type="radio"
          class="delivery-option-input"
          name="delivery-option-${matchingProduct.id}">
        <div>
          <div class="delivery-option-date">
            Monday, June 13
          </div>
          <div class="delivery-option-price">
            $9.99 - Shipping
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

`;
});

document.querySelector('.js-order-summary')
.innerHTML = cartSummaryHTML;

document.querySelectorAll('.js-delete-link')
.forEach((link) => {
link.addEventListener('click', () => {
const productId = link.dataset.productId;
removeFromCart(productId);

  const container = document.querySelector(
    `.js-cart-item-container-${productId}`
  );
  container.remove();
});

});

Code for cart.js:
export let cart = JSON.parse(localStorage.getItem('cart'));

if (!cart) {
cart = [{
productId: 'e43638ce-6aa0-4b85-b27f-e1d07eb678c6',
quantity: 2,
}, {
productId: '15b6fc6f-327a-4ec4-896f-486349e85a3d',
quantity: 1
}];
}

function saveToStorage() {
localStorage.setItem('cart', JSON.stringify(cart));
}

export function addToCart(productId) {
let matchingItem;

cart.forEach((cartItem) => {
if (productId === cartItem.productId) {
matchingItem = cartItem;
}
});

if (matchingItem) {
matchingItem.quantity += 1;
} else {
cart.push({
productId: productId,
quantity: 1
});
}

saveToStorage();
}

export function removeFromCart(productId) {
const newCart = [];

cart.forEach((cartItem) => {
if (cartItem.productId !== productId) {
newCart.push(cartItem);
}
});

cart = newCart;

saveToStorage();
}

12i task

<title>App</title> add remove <script> // i is refer to messages number let i = 0; let intervalID; check(); function check (){ clearInterval(intervalID); if (i > 0 ) { intervalID = setInterval( function(){ if(document.title ==='App'){ document.title = `(${i}) new messages` }else { document.title = 'App' } } ,2000) } else if (i <= 0) { document.title = 'App' } } function addMessage (){ i++; console.log(i); check(); } function removeMessage (){ i--; console.log(i); check(); } </script>

Lesson8 Exercise 8h

In order to be consistent with the video content, it would be more clear to add an alternative solution localStorage.remove('calculation') inside the Clear button.
image

3j.js

Hi,
is the \n missing from the 3j answer or am I just being stupid?
Here's your solution: alert(Total cost: $${(599 + 295) / 100} Thank you, come again!);

This is what I wrote: alert(Total cost: $${(599 + 295) / 100} + \nThank you, come again!);

Thank you for a good course and keep up the good work!

Exercise 7f

Hello, I did this exercise that way below. It is wrong? work the same way that yours.

<title>Conversor de Temperatura</title>
<script>

  function convertTemperature (degrees,unit){
    
    
    if (unit === 'F') {
      const result = (degrees - 32) *5 / 9
      console.log(`'${result}C'`);
    } else if (unit === 'C') {
      const result2 = (degrees *9 / 5) + 32
      console.log(`'${result2}F'`);
    }
  }

  convertTemperature (86, 'F');
  
</script>

15i-soln

the solution doesnot updates the items when updating the code, we have to refresh it

Exercise 14j

Greetings sir, I really appreciate you what you been in my coding journey. I haven't met you before but it seems to me like you are my old friend and your teaching skills is wonderful.
I really don't know while the particular exercise 14j solution is not removing the class list 'is-editing-quantity'. Please someone should help me because I have been stuck here a week now😭

Hey Simon, How can i fix this problem it take too much time, but it didn't solve, but I got one solution which is [ 'cart', '[{"productId":"e43638ce-6aa0-4b85-b27f-e1d07eb678c6","quantityValue":1,"deliveryOptionId":"1"},{"productId":"15b6fc6f-327a-4ec4-896f-486349e85a3d","quantityValue":2,"deliveryOptionId":"1"}]' ] this is only one way, but it has a one problem, if i change any thing or any error but it didn't show this error, please fix this problem and upload short video how to solve this problem, please, please

code-file
error-16i

Issue with Lesson-11 (11u.html)

In lines 24 and 29, reversedFood should have been used instead of foods.

for (let i = 0; i < reversedFoods.length; i++) {
if (reversedFoods[i] === 'egg' && eggsRemoved < 2) {
eggsRemoved++;
continue;
}

result.push(reversedFoods[i]);

I am stuck at lesson 16J

Hi everyone, I have an issue with problem 16j. The problem requires people to have an interactive update button to continue. However, I used a copy of the lesson 16 code from SuperSimpleDev, and the code doesn't have an interactive update button. Someone, please give me the solution to problem 16j, and then I can continue the exercise. I am hard stuck right now. Thank you guys in advance

exercise 8k i checked my code and its the same but still giving error

<!DOCTYPE html>
<html>

<head>
  <title>Coin Flip</title>
</head>

<body>
  <button onclick="
    playGame('HEADS');
  ">Heads</button>
  <button onclick="
    playGame('TAILS');
  ">Tails</button>

  <script>
    const score = JSON.parse(localStorage.getItem('score')) || { wins: 0, losses: 0 };

    function playGame(guess) {
      const randomNumber = Math.random();
      const result = randomNumber < 0.5 ? 'HEADS' : 'TAILS';

      console.log(`ITS ${result}!`);

      console.log(guess === result ? 'You Win!' : 'You Lose!');

      guess === result ? score.wins++ : score.losses++;
      console.log(score);

      localStorage.setItem('score', JSON.stringify(score));
    }
  </script>
</body>

</html>

Lesson 13

How do i generate the Id in product.js.
Const product = [{
id:
name:
}]

Database, server side JS and APIs?

I don't know the full course, I am at lesson 14 and I haven't found a lessons list. When we will get to database and js integrations, server side JS (node.js?) And creation and use of APIs? I really like how the course is explained and I would like to stick with it also for these topics

Problem on the Rock paper scissors projects

I have an error on rock paper scissors projects then rock image does not appear on the screen and I will inspect there is no erron on the console and also in vs code but the image is not appearing and what's is the problem I will try to clear the problem and the next error will appear I will spend more time to solve this but the error will not solved
17183382923163062782960104983738
How can I solve this error

I am not sure where the issue is but the jasmine test system is not recognizing the source file to test.

here I am attaching the info. to debug the issue:
want to test the priceformatter function the code organization is quite similar to the tutorial , the code is also same from the tutorial however the monerTest.js file is in the spec folder which i have given the path to recognize it as a script , code moneyTest.js : import { priceFormatter } from "../../scripts/utils/money";

console.log("test suit: formatcurrancy");

describe('test suit: fromate currancy', () => {
it('convert cents into dollars', () => {
expect(priceFormatter(2095)).toEqual(20.95);
});
});,

test.js :

<title>Jasmine Spec Runner v5.1.1</title> <script src="lib/jasmine-5.1.1/jasmine.js"></script> <script src="lib/jasmine-5.1.1/jasmine-html.js"></script> <script src="lib/jasmine-5.1.1/boot0.js"></script> <script src="lib/jasmine-5.1.1/boot1.js"></script> <script src="spec/moneyTest.js" type="module"></script> .

error; Incomplete: No specs found, , randomized with seed 48042

Variable Section ( -= ) ShortHand Operator

It's not a bug or something, I just find out that I could do the empty cart on another way, so yeah. 

<button  onclick="showQuantity -= showQuantity; 
       console.log('Cart Reset ')">Reset Cart </button>

Lesson 18 (Backend Documentation)

Hey Dev, When I try to place order on Checkout page then it show the error in console (400 Bad Request) for this API =https://supersimplebackend.dev/orders ,can you provide solution for this..
document.querySelector('.js-place-order').addEventListener('click', async ()=>{
const response=await fetch('https://supersimplebackend.dev/orders',{
method:'POST',
headers:{
'Content-Type':'application/json'
},
body: JSON.stringify({
cart: cart
})
});
const order= await response.json();
console.log(order);
});
Lesson 18 Error

****

Not mentioning "product3" but the code still works correctly.

<title>Objects exercise</title> <script>
    function isSameProduct(product1, product2){
    if(product1.name === product2.name && product1.price === product2.price){        **Here I wrote product1 and product2 but nothing about   
                              product 3 (below), the code still works correctly because it                
                              looks at the properties and not at the object name itself ?** 
      return true;
    } else{
      return false;
    }
  }

  const product1 = {
    name: 'ball',
    price: 200
  };

  const product2 = {
    name: 'arrow',
    price: 200
  };

  const product3 = {
    name: 'ball',
    price: 200
  };

  console.log(isSameProduct(product1, product2));
  console.log(isSameProduct(product1, product3));

</script>

lesson 10 bug

document.querySelector('.js-moves').innerHTML = You <img src="images/${playerMove}-emoji.png" class="move-icon"> <img src="images/${computerMove}-emoji.png" class="move-icon"> Computer;

the above code is not working, I have tried to fix it but it won't work. please help.``

stuck at exercise 8i

<!DOCTYPE html>
<html>

<head>
  <title>Coin Flip</title>
</head>

<body>
  <button onclick="
    flippingCoin('HEADS');
  ">Heads</button>
  <button onclick="
    flippingCoin('TAILS');
  ">Tails</button>
  <script>
    let randomNumber = Math.random();
    let result;
    let guess;

    function flippingCoin(guess) {
      if (randomNumber < 0.5) {
        result = 'HEADS';
      } else {
        result = 'TAILS';
      }

      console.log(result);

      if (guess === result) {
        console.log('You Win!');
      } else if (guess !== result) {
        console.log('You Lose!');
      }
    }
  </script>
</body>

</html>

"13m Solution with closure" is not working properly like the "13m Solution with object"

13m Solution with closure: this line "let addedMessageTimeoutId" that is declared outside the loop doesn't achieve the expected result. But when I move inside the loop, it works fine. From what I asked chatGPT, even though this is a more advanced solution, the solution using objects is better in terms of scalability and maintainability. Can I get your opinion on this?

NO SOLUTIONS for the projects

There are 3 projects at the end of the video.

I am struggling with the third one. I have to indicate that a todo is done with a checkbox.

But if I refresh the page, it resets the 'checked' checkbox resets to 'unchecked'.

I tried localStorage, but it doesn't work.

And I literally can't find the solution in the GitHub repo for any of the projects. Are they here?

image

Lesson 13

In the lesson 13, when i added the item into the cart it shows me a “NAN” instead of the number.

console.log(localStorage) is returning "null"

(https://github.com/SuperSimpleDev/javascript-course/assets/92880605/499f5d7c-b17c-4679-a0ad-25c9507c6d20

SCREENSHOT Above

CODE below

import { addToCart, cart } from '../../data/cart.js';

describe('test suite: addToCart', () => {
it('adds and exisiting product to the cart', () => {

});
it('add a new product to the cart', () => {
spyOn(localStorage, 'getItem').and.callFake(() => {
return JSON.stringify({});
});
console.log(localStorage.getItem('cart'));

addToCart('e43638ce-6aa0-4b85-b27f-e1d07eb678c6');
expect(cart.length).toEqual(1);

});
});

From - Lesson 16 (Testing)
Using Jasmine Testing Framework

The above lines of code is supposed to display an empty array in the console since the code is supposed to spyOn locaStorage('getItem')and call fake the cart array, but instead it's returning "null" in the console. I don't know where I went wrong. I need assistance, I have been trying to solve this issue for the past 3 days now.
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.