I’m tryng to achieve if user input on id “comments” is word that is present in my FilterWord’s array then user will be redirected to an url. If input is anything else, then user will be redirected to another url. Checking has to start after user click on submit. Answer Just validate wi…
Tag: arrays
JS list of dictionaries, get first value by condition
Given a list of dictionaries in JS, I want to get the first one that is enabled and not deleted. The dictionary will look like this: I used to take the first one by using objects[0] but now I need to tkae the deleted and enabled in consideration. How can I get the first relevant value? so the results should
Javascript increment a variable in a function
Hey guys I’m new to programming, I need to make a website for school. I want to open the next page when pressing the arrow keys. So I thougt, I can put the URLs into an array an increment the index, when the button is pressed. Unfortunately I get some random numbers from 1 to 3 when I press the
Issue with component array filter
I want to create multiple components and delete them by pressing on button click. I created the components. But i can’t delete it. I wanted to give unique id to the Card component. But when i click one of cards’ buttons,all of cards are gone. I displayed the component array like this: Answer From …
Pick and return a pair of values from an array into two different outputs. JavaScript
I have a function that takes a random element from an array and, at the press of a button, returns the random value to an output. The code is as follows: So far the code is working perfectly, returning to the output a random value from the “questions” array. However, I need to take it a step furth…
Trying to increment an integer in an Array
Good Evening, I am trying to increment an integer that I have index position of ‘0’ in my array, each time my function gets called. I have the variable added with .push, but then I just want to add one to that. I am trying to use indexof(), I have also tried findIndex(). Below is my code Answer Fo…
Mapping in map in json response
I need to parse json api response, with response.data equals: and I need to return one array[String] with all subcategories, ex [“web-development”, “backend-development” … “3D modeling”] All that I did is: and it returns Array of arrays with categories. Im sure, that …
Typescript: typing a function with an array of functions that returns an array of each function return type
Is it possible for the code below to be typed correctly? Answer Managed to do it with Thank you all for your help!!
JavaScript – Adding the totals in Array with same index
I have moved on to learning about looping over arrays and hit a hurdle – did try researching but I think I am probably not describing properly… I have managed to total each line in the array. I did create another variable called total but not sure I needed that… I get the output below, which…
JavaScript: check if duplicate key values exist in array of objects and remove all but most recently added object having that key value
I’m trying to figure out how to check for duplicate values of keys between objects in the same array, then only keep the most recently added object having that value. For example, I have an array of objects I’m trying to filter duplicates of m_id out of, like so: The desired result from the above …