How to print items within an array sequentially

I’m learning Node and I’m attempting to create a readme generator. I’ve created my prompts to confirm if the user would like to add gifs/images to their markdown. I’ve made it so that if the user confirmed then they can enter in the number and then I pass it into a for loop that generators the markdown text for adding an image. What I’m trying to do is to get it to print list style. So far I’ve gotten it so that it’ll print but only as: ![Alt Text](Link or File Path),![Alt Text](Link or File Path),![Alt Text](Link or File Path)

Covert ForLoop to ForEach in Javascript

I was practicing in Hackerrank JavaScript problems. I found one test which is called Compare the triplets. This is the problem: I found the solution like this: I wanted to convert the ForLoop into ForEach method. But I could not find the way to do that. Answer This ain’t what you asked for, but let me show you something: or, less noise: simpler, faster and also shorter. I mean, it’s literally called “compare triplets”. There ain’t any dynamic length or something; and the loop is short. You can easily unroll the loop.

How do I get the function I pass through forEach to reference variables in other scopes?

I don’t know why my findDroids function cannot reference the result variable within my droids function. When I run this code, I get “result is not defined”. Any tips/guidance is greatly appreciated. I’m new to Javascript, so please go easy on me 🙂 Answer Because in JS let variables are scoped to its nearest function. In this case result is only available at droids level. Making the variable global should work: Having said that, using a global variable is probably not the best thing. You can find a needle in a haystack with haystack.includes(needle) to easily check if an array