I feel like I have this right, but for some reason, the addEventListener isn’t functioning how I want it to. When I try to change the img.src below, it still only shows the ‘images/expand.jpeg’ img. I have confirmed that the path to the image is correct, as it does show the ‘images/col…
How do I toggle the elements with its corresponding button by mapping through an array in ReactJS?
I’m mapping through an array from a JSON. How do I get the button to toggle the display of the div containing listOfGrades with the ID? So 20 buttons for 20 listOfGrades divs, and each button should toggle its own corresponding div. Thanks! Answer You can add a property in your data which keeps track of…
Set variable to method
I want to make a shorthand library for myself, ex: shortening querySelector to get. would there be a way to return just the method without document? EXAMPLE: Thanks. Answer You have to call .querySelector on either the document or an element. It can’t be left off. While you could pass it into the functi…
Targeting textual data to a DIV on a web page?
I have a web page – index.html on a localhost webserver – split horizontally via DIV elements and a CSS stylesheet into upper / lower panes. Titles (hyperlinked to source HTML documents) appear in the upper split. Task 1. When I click a hyperlinked title, the output is targeted to a DIV on index.h…
Issues with conditional rendering react
So I have read quite a lot about react conditional rendering on the official docs and on STO as well but I have some issues and doubts. My objective here is I’m trying to check if the value of {game.embed_url} is NULL then no <iframe> should be rendered, else <iframe> should be rendered, Ofc…
Javascript – Stuck in an if statement – Beginner Question
I am trying to make a calculator, simply my problem is this: Page refreshes. User clicks on any number and the number gets added to the First Number: nums_clicked h1. If user clicks on an operator sign(+ – *), the clicked boolean becomes true. If clicked is true, add the numbers clicked to the Second Nu…
Arrow function that expects 2 numbers and returns undefined if they aren’t numbers
Need help. Need an arrow function that expects 2 numbers as input (e.g. 1, 2) and returns the sum of the two numbers. If anything other than 2 numbers is passed, return undefined. Not sure where I’m going wrong on this. Just keeps returning undefined, and doesn’t go to finding sum. Answer Use isNa…
Spread Operator – TypeScript
I’m trying to pass an array as an argument with Spread operator but something is going wrong. Answer For TypeScript to correctly predict what argument types are going to spread into the parameter, you will have to change the args variable type into a tuple as follows:
Puppeteer , bringing back blank array
I’m trying to grab products from ebay and open them on amazon. So far, I have them being searched on amazon but I’m struggling with getting the products selected from the search results. Currently its outputting a blank array and im not sure why. Have tested in a separate script without the grabTi…
How to “store” data from an API call and refresh it (make new call) overtime (replacing old stored contents) on website
I’m a volunteer for this association/game called FAF. We have a leaderboards (https://www.faforever.com/competitive/leaderboards/1v1) of players that we get through API calls. However, it isn’t very efficient to make it so everytime someone opens the leaderboard page to make an API call to get the…