I’m currently trying to insert text content that change depending of image validation using a single class for multiple divs. Any help is appreciate! HTML Right now using the next Javascript it’s inserting the text content but it only does it once per “.spanner” class, not in the rest. JavaScript I’m trying to figure out how to make it work
Tag: foreach
How to use the result of an iteration to re-iterate?
I need to create a new array from another with the condition: for example from an array I need to make an array [‘1′,’2′,’148′,’151’] which means the path from “parentId”‘s to “id”:152 – (argument for this function). I think main logic can be like this: and the result {item.parentId} should be used to iterate again. But I don’t understand how
How to get a property value from an array of objects in JavaScript
I want to make an array with country names from a JSON file which contains an array of objects. These objects have a property name with the name of the country, which is what I need. This is my JavaScript code which returns a list of undefined instead of country names: In the other hand, if I use forEach, I
Fill array with prompt in JavaScript and use push method
I am learning arrays in JavaScript and I am using the foreach with the push method. The following code is working as its supposed to: But I want to replicate this with a prompt, instead of hard coding the values in the array. And end the prompt with a 0. The code I attempted is the following, but the variables
How to start item index with 1
I’m iterating through array “fruits”. I want its index to start with 1. but the output starts at 0. Here is my code here is the output. how do i make it to start with 1 ? Answer Manually add 1 to the index:
get data from all documents in an collection firebase firestore
i need to get the data of all the documents of a collection in the firestore. but in my forEach I am getting only the first document and I have two. he prints the console twice but in my setPoints state he puts only the first what I am doing wrong?? Answer I don’t immediately see what’s going wrong in
How can I send a Discord Direct Message to all users on a server on API v12?
I’m trying to update my discord bot from API v11 to API v12, and I’m having problems to send a direct message to all server users. It is not returning any error and I’m using the latest version from Discord API This is the function: Could someone help me? Answer First of all, depending on the size of the server,
Need to display some data from JSON for user if they are checked
The JSON is a nested one. at first it will display some services for the user with check-boxes, then user can check them if he is interested. When he clicks the button it should to display the service info of which user wanted. I really appreciate if anyone can help, I am new to json. I have one HTML and
Covert ForLoop to ForEach in Javascript
I was practicing in Hackerrank JavaScript problems. I found one test which is called Compare the triplets. This is the problem: I found the solution like this: I wanted to convert the ForLoop into ForEach method. But I could not find the way to do that. Answer
How do I get the function I pass through forEach to reference variables in other scopes?
I don’t know why my findDroids function cannot reference the result variable within my droids function. When I run this code, I get “result is not defined”. Any tips/guidance is greatly appreciated. I’m new to Javascript, so please go easy on me 🙂 Answer Because in JS let variables are scoped to its nearest function. In this case result is