JS Assignment 16: Using Callbacks in Array Methods
I have gotten to the last exercise of the last assignment in the precourse work for Web Development for Lambda and I am stuck. I am relatively new to the world of programming and after spending two days trying to figure this out on my own, I need some help!
function exerciseTwo(cents){
// Exercise Two: In this exercise you will be given an array called 'cents'
// This array is a list of prices, but everything is in cents instead of dollars.
// Using the map method, divide every value by 100 and save it as a new array 'dollars'
// Please write your answer in the lines above.
return dollars;
}
It looks really good, I'll do it now, love for you
driving directions
Same exercise . this is what I have so far
let DollarsInCents = cents.map(DollarsInCents / 100);
I will help you get started and give you a hint, but I want you to figure this one out because it'll be hugely satisfying once you do! I promise!
But, here is a hint:
You're going to use the
map
method of course. What map does isapplies some set of programming to every item in an array
.So, let's say I have an array of
[10,20,30]
. I want to divide each one of those by 10 and see the result:You'll see that in the above I just divided everything in the array by 10 and the result was
[1,2,3]
. Use this same logic in your function!@heyitsmarcus That wasn't a hint. You told just everything.
@ApoorvSingal This exercise is so simple that it's almost impossible to not give away almost everything. But, I didn't write in the final step.
@heyitsmarcus thank you so much! The map method is difficult for me to wrap my head around for some reason.
@kkleiman90 I hope it made more sense for you after this. I can write a little problem for you and help you through it with
map
if you'd like?