JavaScript Array Method Exercises 01

preview_player
Показать описание

In this video, you'll get some practice with JavaScript Array Methods by completing some practical exercises.

Jump to any of the exercises:
01:15 Exercise One (02:50 Final Solution)
03:04 Exercise Two (04:13 Final Solution)
04:27 Exercise Three (05:30 Final Solution)
05:50 Exercise Four (06:31 Final Solution)
06:50 Exercise Five (08:32 Final Solution)

In the tutorial, you'll learn about various different array method available in JavaScript by completing some simple exercises on an array of data i'll provide you with.

Don't worry if you get stuck - i've provided example solutions but feel free to post your own if you come up with something different.

So to solve these JavaScript array methods exercises you'll need to call on several JavaScript functions that may or may not include:
- JavaScript filter
- JavaScript map
- JavaScript reduce
- JavaScript forEach

In fact using the JavaScript map reduce filter functions with JavaScript arrays can solve a multitude of problems and you can probably solve all of these JavaScript exercises with a combination of the above JavaScript functions. Of course each JavaScript exercise can also be solved multiple ways.

Hopefully you'll find these JavaScript exercises for practice useful and might be a bit more involved than some basic JavaScript loops exercises. So enjoy these JavaScript exercises and solutions!

#JavaScript #Practice #Exercises Channel Handle @codewithbubb
Рекомендации по теме
Комментарии
Автор

Got your own solution to one of the exercises? Post it as a comment below!

codewithbubb
Автор

This is what I've been looking for! There's no better way to practice array methods. Reduce is a great method, this video helped me shed more light on it!

Elator
Автор

const depCount = people.reduce((acc, person) => {
acc[person.department] ? acc[person.department]++ : acc[person.department] = 1; //if the dep already exists, just add one : otherwise make the new dep equal to one.
return acc;
}, {});

console.log(depCount);
- I think this method makes more sense IMO. Hopefully it helps out people who are struggling

chubbyBunny
Автор

The real work on JavaScript you make thanks for these awesome tutorials

mahmoud_awad
Автор

Hi,
For the last question, I would like to know why you have the value of the accumulator spread back. I was confused there

christianotu
Автор

Great work ...Exercise 5 was very difficult. I am just a beginner self learning the JavaScript, could you please help me how to understand or get to know about these kind of techniques ?

GauthamHC
Автор

The last one is hard to understand, but Thanks a Lot for the video!

igoroliveira
Автор

Very nice tutorial, you have explained the javaScript array methods very well.

techwithdanyal
Автор

I love your videos, thank you so much for posting these! I wish you were my lecturer right now lol

tatumevans
Автор

you've got yourself a subscriber!! apprtiate your work!!! love from Nepal;)

lyrichives
Автор

hello, someone can explain to me in exercice 1 : the meaning of 0 just after "person.salary"? thank's

dapydoe
Автор

Hello... Since when I saw this exercises... I have been so so so confused... 🙀.
This is a month plus.. Since I started learning javascript.. But am still not comfortable.. When I read books and online materials I understand but.. Exercises.. I don't understand.. Any advice? Or recommendation ?

ephraimray
Автор

for the first one:
let totalAvarge = 0
for (let i = 0; i < people.length; i++) {
let incomeAvarge =
totalAvarge += incomeAvarge;

}
console.log(totalAvarge)

myshuker
Автор

Day 3 and still struggling with your approach with question no. 5 😅
I too want to solve it in few lines .but couldn't
my lengthy solution to it, how most others would do it😁:-

function departmentCounter(dept = ['Development', 'Marketing', 'Sales', 'Office Management']){

finalArray = [];
dept.map( element => {
count = ((people.filter(item => item.department == element)).length);
finalArray.push( element+ ": "+count)}
)
return finalArray
}

log(departmentCounter())

jitulborah_
Автор

i dont get it where thar person var comes from ?

MenAmongTheRuins
Автор

That last exercise killed me, I don't think I'll ever be able to solve something like that.

XlON___
Автор

With your solution I have this in terminal: { Development: 6, Marketing: 2, Sales: 3, 'Office Management': 1 } How can I make 'Office Management' not to be a string?

tomsstasulans
Автор

why u use dollor symbol in some functions
pls explain me

sathamhussain
Автор

I'm kinda confuse. What does the ...acc do in the last exercise solution?

teyvatchronicles
Автор

Ex 5 here is my solution.I think it isn't modern but just work

const departments = [];

people.forEach((i) => {
  if
});

for (let i = 0; i < departments.length; i++) {
  const sd = people.filter((x) => x.department == departments[i]);
 
}

shahlamli