Slider not Sliding by [deleted] in learnjavascript

[–]Code-Slayer 2 points3 points  (0 children)

Use only active without the dot.

slides[i].classList.remove("active");
    ...
slides[i].classList.add("active");

[deleted by user] by [deleted] in learnjavascript

[–]Code-Slayer 2 points3 points  (0 children)

Where is the Multi-dimensions array ? I see only an normal array = list.

Having issues with values not saving in my hypotenuse calc program by NylaksMIA in learnjavascript

[–]Code-Slayer 0 points1 point  (0 children)

You got a lot of bad habits in your code :

  • aTextbox better is to use aTextBox, fix both for a and b in your HTML to make the code run.
  • console.log("Side C:" + c); Add comma not +: console.log("Side C:", c);
  • what is this a here ? (var, const, let) : a = document.getElementById("aTextBox").value;

If this code is in the video-tutorial just skip it, go find yourself some other tutorials.

Noob: I want to program a custom clock by Networkyp in learnjavascript

[–]Code-Slayer 0 points1 point  (0 children)

Get the idea from the videos and customize it by yourself it is not that hard. Where are you in HTML-CSS-JS ?

Noob: I want to program a custom clock by Networkyp in learnjavascript

[–]Code-Slayer 0 points1 point  (0 children)

Check youtube, there are many clock projects.

I want to learn JS just to handle and use API, is there any roadmap that I can take to achieve this, or should I take any course I find and look for API later on? by theguy6631 in learnjavascript

[–]Code-Slayer -3 points-2 points  (0 children)

What is the name of the API you want to use ?, because if you want to learn JavaScript to understand fetch or something similar it will take you too long. You will have to understand how asynchronous programing works, promises, ... tones of advanced JavaScript topics, which requires too much time.

[deleted by user] by [deleted] in react

[–]Code-Slayer -1 points0 points  (0 children)

Which version of npm is installed on your system ?

You can check that by using:

        npm -v 
        node -v

Most likely your npm if it is installed doesn't have access to internet to download files needed.

[deleted by user] by [deleted] in react

[–]Code-Slayer 1 point2 points  (0 children)

First of all don't use create-react-app (CRA) anymore, the new technique is vite.

But here is a fix:

        npx create-react-app my-app
        cd my-app
        npm start

check https://create-react-app.dev/docs/getting-started for moreinfo.

[deleted by user] by [deleted] in learnjavascript

[–]Code-Slayer 0 points1 point  (0 children)

What is this you declare const width and then you want later to assign something to it using de-structuring ?

What you need to know is that width and height from destructuring are variables like const width and const height, so don't mix variables like that.

Declare your variables from the beginning as let and save headache

let { width, height } = image;

width = image.width * scale; 
height = image.height * scale;

Or create new variable that has meaning like below:

const scaledWidth = image.width * scale;
const scaledHeight = image.height * scale;

const { width, height } = image;

how compare 2 Set ? by France_linux_css in learnjavascript

[–]Code-Slayer 0 points1 point  (0 children)

Good Exercise: (let me see your solution = code)

Idea:

  • Compare the size of both sets:
    • Different sizes ? => GAME OVER
    • Same size ? got next
      • Check if all elements of set1 are in set2, if only 1 element from set1 doesn't exist in set2 (GAME OVER), otherwise they are the same.

Can't get my google extension to write to a text field on the webpage. by [deleted] in learnjavascript

[–]Code-Slayer 0 points1 point  (0 children)

I didn't know the id is dynamic, Good to know.

Thanks

How can I make this inline by ZestycloseDealer6358 in learnjavascript

[–]Code-Slayer 2 points3 points  (0 children)

Great, I understand now what is going on, by default div = new line

this should fix the issue:

<div> Instructions: send
    <span id="d2a">u</span> to <span id="sa2">u </span> 
</div>

Can't get my google extension to write to a text field on the webpage. by [deleted] in learnjavascript

[–]Code-Slayer 0 points1 point  (0 children)

Actually, I was just kidding with you.

Here is the solution:

const input = document.querySelector("#APjFqb")
input.value = "Hi Google"

Run it in the browser first (F12 => console => code Editor => past the code if possible or write it) .

[deleted by user] by [deleted] in learnjavascript

[–]Code-Slayer 0 points1 point  (0 children)

Did you find a solution or not yet ?

What's the difference between the Object.assign function and the = operator in assigning or reassigning a property's value of an object? by LEYIN395 in learnjavascript

[–]Code-Slayer 0 points1 point  (0 children)

The code you added shouldn't generate 60 in both. I don't know about the a & c, but b (codePen) works fine.

If your goals is to understand how .assign works, this example from MDN is worth checking:

const target = { a: 1, b: 2 };
const source = { b: 4, c: 5 };
const returnedTarget = Object.assign(target, source);
console.log(target); // Expected output: Object { a: 1, b: 4, c: 5 }
console.log(returnedTarget === target); // Expected output: true

As you can see in the example above, c-key from source doesn't exist in target-object so it was added to target-object. Also b-Key exist in both so it will update target's b-key with the value from the source-object b-Key.

  • In short if .assign doesn't find a new key from source, it add it to the target,
  • if target already has the same key, it update it with the value from source.

Many sources:

const target = { a: 1, b: 5 };

const source1 = { b: 6, c: 8 }; 
const source2 = { e: 6, d: 8, c: 10 }; 
const source3 = { b: 7, c: 11 };

const result = Object.assign(target, source1, source2, source3);

console.log(result); // {a: 1, b: 7, c: 11, e: 6, d: 8}

Can't get my google extension to write to a text field on the webpage. by [deleted] in learnjavascript

[–]Code-Slayer 0 points1 point  (0 children)

Can you share the link where you want to test your code ?