constvisitedLinks=newSet(),visitedIds=newSet();// Just in case somebody gets tricky and adds unique links that have duplicate IDsasyncfunctionvisitLink(link){lettotal=0;if(!visitedLinks.has(link)){visitedLinks.add(link);const{id,content,links}=await(awaitfetch(link)).json();if(!visitedIds.has(id)){visitedIds.add(id);total+=parseFloat(content.match(/\$[\d,]+(?:[,.]\d+)?/)[0].substring(1).replace(',','.'));for(constlinkoflinks){total+=awaitvisitLink(link);}}}returntotal;}visitLink('https://gist.githubusercontent.com/jorinvo/6f68380dd07e5db3cf5fd48b2465bb04/raw/c02b1e0b45ecb2e54b36e4410d0631a66d474323/fd0d929f-966f-4d1a-89cd-feee5a1c5347.json').then(console.log);// 9064.78999999999 (JS rounding errors, yay)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Discussion on: Code Challenge: Follow the Dirty Money
For further actions, you may consider blocking this person and/or reporting abuse