I have an array of topics each linked to a parent topic. So, basically what I want to do is form an array with all the children topics nested under the parent. So if I had an table of topics looking like this: id name parent_id 1 Topic 1 null 2 Topic 2 1 3 Topic 3 2 4 Topic
Tag: loops
How to walk through the object/array in javascript by layers
I am converting the nested data object to the arrays, for the UI Library to show the relationship between the data. Original Preferred Result To do this, I write the code like this: It works. However, I miss one important things, the library need the layers from the original data, to determine the type/ what function to do. Editing the
Looping through and reducing nested array
I can’t seem to get my head around the array.reduce() function. I’ve got the following array: and I’m trying to get a result like below. I’m not sure how to go about multiplying the ingredient amounts with the item quantities: I’ve tried following the structure that was given here but the arrow function is throwing me off. Any sort of
Dynamically append the element through JavaScript Dom
Hers’s question which I need answer Exercises: Level 1 Question 1 I tried to append the child dynamically and get the result vertical not in the compact manner as you will see in the question output when you go to the link You can see the code of both HTML and javascript above!!! Do help with the code where I
Can’t get values past array[0] to translate properly
Okay, to start with I should mention this is a very small personal project, and I’ve only have a handful of coding classes several years ago now. I can figure out a lot of the (very) basics, but have a hard time troubleshooting. I’m in a little bit over my head here, and need a dumbed down solution. I’m trying
Changing Values in a Form Causes Lag
I want to change the value of a from once a second, but when i use this code: The tab completely locks up, and I am forced to reload it. I have also tried using document.getElementById(“input”).value = “value”;, but that causes the same thing to happen. Does anyone know how to fix this (the form does not have a name)?
Loop prompt when input isn’t a month
I’m trying to loop the prompt when the user enters incorrect input. I googled and clicked almost all the top links, tried while loop and for loop and am just not getting anywhere. When I use the method i found of a loop, my button is no longer clickable or it clicks but when I input invalid month, no alert
Adding strings returns empty string in Javascript
My goal is for this function to return only “03.12.21, 16:12:52”. Currently only “]” is returned. Answer Move let date = “”; outside of the loop (you are resetting it each iteration)
How can I loop through two sets of numbers?
I’ve got two small puzzles that I can’t quite figure out! I need to loop through two sets of numbers indefinitely, one first and then the other with a 10 second pause between each one in which both values go back to -1. Both start at -1 and both go up to 2. I can loop through the first number
date copy stops the loop statement to function as intended
What i am trying to do is to display available rooms which are in data i map the rooms using data.map , check if one is available between a given ( checkin and checkout date ) using availdata[p.roomId][date].i==0 , if not it will display the available room . the code works fine but as soon as it finds an available