{"id":19168522,"url":"https://github.com/oneted11/understanding-recursion","last_synced_at":"2026-06-11T20:31:42.907Z","repository":{"id":123735345,"uuid":"452190538","full_name":"Oneted11/understanding-recursion","owner":"Oneted11","description":"Understanding Recursion as a concept ","archived":false,"fork":false,"pushed_at":"2022-02-12T05:58:38.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T23:28:42.970Z","etag":null,"topics":["algorithm-challenges","console-log","html5","javascript","recursion-exercises"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Oneted11.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-26T08:08:14.000Z","updated_at":"2022-05-19T06:42:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae43ed7e-a773-4e72-9477-32a3cbfc25eb","html_url":"https://github.com/Oneted11/understanding-recursion","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Oneted11/understanding-recursion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oneted11%2Funderstanding-recursion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oneted11%2Funderstanding-recursion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oneted11%2Funderstanding-recursion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oneted11%2Funderstanding-recursion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Oneted11","download_url":"https://codeload.github.com/Oneted11/understanding-recursion/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oneted11%2Funderstanding-recursion/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34217312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm-challenges","console-log","html5","javascript","recursion-exercises"],"created_at":"2024-11-09T09:42:59.555Z","updated_at":"2026-06-11T20:31:42.880Z","avatar_url":"https://github.com/Oneted11.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Understanding Recursion\n\nTrying to understand recursion\n\n## Learning resources\n\nI'm currently using\n\n### Theory\n\n- https://www.geeksforgeeks.org/recursive-functions/\n\n### Exercise\n\ntrying to do\n\n\u003e Try to calculate a sum recursively without Array.reduce by implementing a function which accepts an array of numbers and an accumulating parameter. Take one element of the array and add it to the accumulator.\n\nas suggested on this [tweet reply](https://twitter.com/flosalihovic/status/1485865331562274816)\nprompted by my [tweet](https://twitter.com/reithi_254/status/1485818354464169987) about not having a deep understanding of recursion and array.reduce\n\n# How to run\n\nYoure gonna need a server and point it towards index.html.\nIf you're using [visual studio code](https://code.visualstudio.com/) you can use [five server(Live server)](https://marketplace.visualstudio.com/items?itemName=yandeu.five-server) . It's what I'm using\n\n# Trial One\n\n./index.js\n\n```javascript\n// console.log(\"hi there\");\nconst myarr = [9, 8, 3, 6, 7, 4];\n\nconst accumulator = function (acc, arr) {\n  // console.log(\"bloody arr\", arr);\n  //do add to acc\n  // console.log({ acc, arr });\n\n  if (arr.length == 0) {\n    return acc;\n  } else {\n    const num = arr.pop();\n\n    acc = acc + Number(num);\n    // console.log(\"logging steps=\u003e\", acc, \"with\", num);\n    accumulator(acc, arr);\n  }\n};\n\nconst calling = accumulator(0, myarr);\n\nconsole.log(\"calling\", calling);\n```\n\nIt failed to return the answer even through it breaks at the right point.\n\n## Added callback with the help of a friend\n\n./index2.js\n\n```javascript\nconst myarr = [9, 8, 3, 6, 7, 4];\n\nconst accumulator = (arr, acc = 0, done) =\u003e {\n  if (arr.length == 0) return done(acc);\n\n  const num = arr.pop();\n  acc = acc + Number(num);\n\n  // log for visibility\n  console.log({ num, acc, arr });\n\n  accumulator(arr, acc + Number(num), done);\n};\n\nconst handleAccumulatorFinish = (accumulated) =\u003e {\n  console.log(\"accumulated\", accumulated);\n};\n\nconst accumulated = accumulator(myarr, 0, handleAccumulatorFinish);\n```\n\n## shortened and simplified version\n\n\u003e the chad version\n\nindex3.js\n\n```javascript\nconst myarr = [9, 8, 3, 6, 7, 4];\n\nconst adder = (arr) =\u003e {\n  // return zero when array is finished\n  //doesnt return without it\n  if (arr.length === 0) return 0;\n  //call adder with the remaining array after adding the last item through popping\n  else return arr.pop() + adder(arr);\n};\nconsole.log(adder(myarr));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foneted11%2Funderstanding-recursion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foneted11%2Funderstanding-recursion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foneted11%2Funderstanding-recursion/lists"}