About 788,000 results
Open links in new tab
  1. My recursive function (javascript) always return false, even when it's true

    It always return false, even when it's true. if(start > end) { return false; let mid = Math.floor((start + end) / 2); . if(mid === nameToFind) { return true; if(nameToFind < tableaux[mid]) { return …

  2. recursion - javascript return of recursive function - Stack Overflow

    You need to return the result of the recursion, or else the method implicitly returns undefined. Try the following: this.func1 = function() { var result = func2.call(this, "haha"); alert(this.iteration + …

  3. How to check if number is even using recursive function in JavaScript

    Oct 1, 2020 · var isEven = function (n) { if (n > 0) { return positive(n); } else { return negative(n); } function negative(num) { if (num === 0) { return true; } else if (num === -1) { return false; } else …

  4. Trtying to understand recursion - Why doesn't my function return true

    The most common misconception with recurion is that any return statement in a recursive function returns immediately to the top level. So, in your case, that the return true on line 4 would get …

  5. JavaScript Recursive Function

    This tutorial shows you how to use the recursion technique to develop a JavaScript recursive function, which is a function that calls itself.

  6. Recursive functions returning a Boolean : r/learnprogramming - Reddit

    Aug 21, 2021 · How do recursive functions returning a Boolean work? For example, to recursing through a list, returning true if 10 is in the list, but false if not, recursing one element at a time …

  7. Recursion Guide in JavaScript - GeeksforGeeks

    Feb 14, 2025 · Some common use cases include: Tree and Graph Traversals: Recursion is ideal for traversing hierarchical data structures like trees and graphs. Divide and Conquer …

  8. JavaScript Recursion (with Examples) - Programiz

    If count > 1 evaluates to true, the program decreases the value of count and calls counter() with the new value of count (recursion). Otherwise, if count > 1 evaluates to false, the program …

  9. Recursive method in javascript always returns undefined instead of true

    Jun 12, 2015 · The problem is in your first if statement console.log("len", x.length, "result",result); if ((!result) && (x.length > 2)) { console.log("recursively calling"); addUp(x.slice(i+1, x.length), …

  10. How Does Recursion Work? Simplified in JavaScript with Examples

    Oct 7, 2022 · Recursion works similarly to how loops do in JavaScript. Loops allow you to execute a set of code multiple times as long as a condition is true. In this article, I will explain what …

  11. Some results have been removed