Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 months ago. Improve this question I’m trying to print out the multiplication table using js. Is there a cleaner way to do this than with nested
Tag: nested-loops
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
Javascript array recursion question – looping through “sections”
I’m strugguling with Javascript on how to find all combinations of an array source with n depth that is broken into sections (0, 1, & 2 in example below). I want to end up with each possible cominbation – and each returned array should include one and only one value from each group. I’ve hardcoded a solution to 4 levels,
Generate and sort cartesian coordinates around (0,0) in all quadrants using Javascript’s nested array loops
I have an variable obj that has the element count that needs a cartesian coordinate. So I want to generate the following matrix. obj = 9, Square root of obj = 3, 3×3 matrix (-1,1) (0,1) (1,1) (-1,0) (0,0) (1,0) (-1,-1) (0,-1) (1,-1) obj = 25, Square root of obj = 5, 5×5 matrix (-2,2) (-1,2) (0,2) (1,2) (2,2) (-2,1)
Changing the keys of a nested object in an Array with JavaScript
I need to change the keys of my object. I could use the map function to change the keys of my outer object. Question is, how can I access the inner object which is in an array as well. In the code below, I need to change the team key to teamName. My structure has to be in the same
Any way to generate javascript or pseudo code for a Data Flow?
I have a web form where users answer questions via dropdowns, and I wish to make other questions available based on their responses. e.g. if your business has a premises then ask about opening hours. If they don’t, show the regions they operate in. With each question I add to the process, the more complex the code becomes. A lot
Is using labels in JavaScript bad practice?
I just found out about using label s in JavaScript, such as: I’ve not heard about this until now and I can’t find much information online about it and I’m beginning to think there is a reason for that. It seems to me like this is similar to a GOTO statement in other languages and would be considered bad practice.