How to find path from tree of nodes

Consider a data structure similar to the one below: [ { name: ‘Link1’, url: ‘link1’, }, { name: ‘Link2’, url: ‘link2’, }, { name: ‘Link3’, url: ‘link3’, submenu: [ …

CodeSignal reverseParentheses Failing one case

Write a function that reverses characters in (possibly nested) parentheses in the input string. Input strings will always be well-formed with matching ()s. For inputString = “(bar)”, the …

converting number bases to string using a recursive function javascript

I’m trying to write a recursive function that takes two parameters – an integer input, n, and an integer base, m – and returns a string representation of the number in Base m. I’m stuck can someone …

How to properly call a recursive function inside a for loop?

I’m trying to implement a method that takes as a parameter: target string and an array with string values in it. The goal is to check if it is possible to construct with array’s value, the given …

Why is this recursion example giving me an infinite loop?

This is driving me insane. Here is the code : function laugh(){ let counter = 10; if(counter <= 0){ return; } else{ console.log('laugh'); counter--; laugh() } } Why ...

How to build map for large json with unknown structure

I have large json data with unknown depth and I need to build a map in the following format of result. const json = { 1: { 11: { 111: [{ “111-0”: “b” }, { “111-1&…

Counting up and down in recursive manner in JS

I am currenty working on functional programming techniques. There are topics about this issue [ especially there is one about java ] but not about JS. I want to create a recursive function that can …

Recursive counting in arbitrary nested object

I’m attempting to do some data visualization and dealing with this dataset. Object with arbitrary nested objects. I’m trying to count how many times different values appear in a key. This is just a …

How to recursively construct an JSON hierarchy from a NodeList?

Given the following input:

Title A

Title A- A

Recursively Search in Array with a For Loop

I know there are better ways to search an array, but I really want to understand how to return when the value is found in a recursive call. Logging when found isn’t a problem, but I can’t seem to …