My application references a database object that acts as a catalog. It’s a catalog of items that can be crafted if the user has the necessary components. Here is a small sample of the catalog: When the user has the necessary components for any given item, the user can assemble that item. The user is awarded components arbitrarily and randomly,
Tag: recursion
How to wait for a function, which calls itself recursively with setTimeout, to complete?
I am new to Javascript and currently working on a website, that changes how it looks by itself over time. One part of this page is a “Typewriter”, that writes out a text letter by letter. This is the code for this Typewriter: Now I want to wait for the typewriter-function to finish with its text before doing another change
Use recursion on array [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question Write a function that by given array of integers, and a positive number X, returns the product of all odd
Trying to recursively hash values in object
friends. I’m trying to write code that hashes all values in a JSON file, regardless of file structure, while preserving the keys and structure. I’m new to javascript, and am having some trouble. My code hashes the values of big and baz, but doesn’t recursively hash the values of cat and bar like I want it to. Ideally, I want
happy number algo question solution not working
trying to figure out this coding problem: Write an algorithm to determine if a number n is “happy”. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or
Search nested array of objects and return whole path of all matching items
I would like to search a deeply nested array of objects and return the path of all matched objects. I have partial solution of the problem but the code returns path of only first matched object. Please have a look at the input, expected output and the code itself. I have commented the desired logic in the expected output section.
How does the cache update in javascript memoized fibonacci recursive function?
Considering the following recursive Fibonacci function that’s been optimized using memoization. No other code apart from this. Can someone please explain how is the cache array updated? When viewing the console logs the cache seems to hold all the previous values from the resolved recursive functions. But to me, this doesn’t make sense as the cache is not stored outside
Recursive Add method for BST using Javascript not working
Below is the implementation of a BST with an insertion function for it. currently, the code wouldn’t work; It would just spit out Tree { root: null } When i tried to debug it, it seems that it successfully adds the new Node to the correct spot, but once it returns from the function, all that data is lost and
Javascript – recursively remove nodes of a certain type from tree, but reattach and spread eligible children
I’m writing a recursive function on a JSON tree {name, type, [children]} to remove nodes of a certain type. However, the children of the removed node should get re-attached to the parent, if they are not of the type to be removed. I’m experiencing the following difficulty: Let’s say I want to remove type b on the following tree: The
Traversing recursively through an array and modifying values of object properties in JavaScript
The post may seem lengthy but it’s quite easy to follow, if not, I will add more details I have criteria array which that looks like : Characteristics of criteria: It could have nested arrays. First item array (or nested array) is always going to be either “and” or “or” Second item onwards in array, item could be either an