Skip to content
Advertisement

Tag: nested-loops

Use reduce instead of nested for loops? [closed]

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

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

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)

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.

Advertisement