I am making a game with img´s each time that the user clic on the correct img win 100 points but i dont get the summations of the points i dont know why The final score still 0 HTML JS Answer I have made the finalScore as global variable and moved the logic to a function. It is working as
Tag: loops
How to carete dynamic NavBar with only JavaScript
I have this code right now, but its not working on the DOM, I am wondering what is the problem with my code. My current code: “JavaScript” “HTML” < Answer call the function or avoid the function. try it
How can I remove duplicate strings from an array of strings but only if they start with the same 5 characters in JS?
I have a nodelist: Every “a” contains a string In the example the list is like that: I need to remove for example the the third element because it starts with the same 5 characters of the second element even though they end differently. Everytime I encounter a new element I need to check if there’s another element in the
Looping through an array of objects and filter using a key
I have a nested array of objects as below I would like to loop through the array and get the address object corresponding to the firstName ‘Max’. I can use this data to generate links and their sublinks (on clicking the links) I have attempted the following Then But it returns undefined. How can solve it? Answer You should look
Apply discount on array of object in loop whichever object paid value is higher?
I have array of object which have key paid. I want to apply discount on all objects expect object which paid value is higher using loop. On above array of object name booking i want to make loop and apply discount by adding key discount:true in that object except higher paid value object. This is what i want after loop
Looping elements in JSX React
In React.js documentation, I wonder how Array.map() is used in JSX React. in <ul> tag, why we just put the variable listItems directly?. Because I think it will return a single array instead of <li> elements like this : how does JSX treat an array? Did I have to loop listItems manually? Thank you in advance. Answer you might want
How to declare item types of a zipped list in typescript?
I have two lists like these: and combined them using zip: Then, I want to apply a map on the zip like this, for example: The ‘item’ in the code above implicitly has an ‘any’ type, so I want to define the type like: but this doesn’t work. Does anyone know how to define the type, for a case like
This code keeps returning ‘undefined’ for (names[i]). what am I doing wrong?
This code keeps returning ‘undefined’ for (names[i]). When I console.log() it loops through the array and prints Hello (names[i]) or Good Bye (names[i])what am I doing wrong? Answer Your issue is that you’re passing the name in as an argument to the speak function, however, in your definition of speak it doesn’t take an argument at all. You can fix
how can i make all if statements in a loop ? in Javascript
i’ve already tried a for loop but I’m new to javascript so it’s all still hard for me. I am grateful for any help. It should increase values. here´s my code: and so forth. Answer
Javascript: Object.keys(myarray).forEach vs myarray.forEach((obj) => {
Is there an alternative way of looping through my array of objects? it seems the engine version on the application im using is old and doesnt support myArray.forEach((obj) => { but this works on an single object array I think. Object.keys(myArray).forEach( {“jurisdiction”:”SCPB – LON”},{“firstName”:”David Dynamic”} Error produced by the webapp Also tried a loop to no avail. JST-310000 Error while