JavaScript map() method in 7 minutes! 🗺️

preview_player
Показать описание
00:00:00 introduciton
00:00:16 example 1
00:02:13 example 2
00:03:58 example 3

// .map() = accepts a callback and applies that function
// to each element of an array, then return a new array

// ------------ EXAMPLE 1 ------------
const numbers = [1, 2, 3, 4, 5];

function square(element){
}

function cube(element){
}

// ------------ EXAMPLE 2 ------------
const students = ["Spongebob", "Patrick", "Squidward", "Sandy"];

function upperCase(element){
}

function lowerCase(element){
}

// ------------ EXAMPLE 3 ------------
const dates = ["2024-1-10", "2025-2-20", "2026-3-30"];

function formatDates(element){
return `${parts[1]}/${parts[2]}/${parts[0]}`;
}
Рекомендации по теме
Комментарии
Автор

// .map() = accepts a callback and applies that function
// to each element of an array, then return a new array

// EXAMPLE 1
const numbers = [1, 2, 3, 4, 5];
const squared = numbers.map(square);
const cubed = numbers.map(cube);

console.log(cubed);

function square(element){
return Math.pow(element, 2);
}

function cube(element){
return Math.pow(element, 3);
}

// EXAMPLE 2
const students = ["Spongebob", "Patrick", "Squidward", "Sandy"];
const studentsUpper = students.map(upperCase);
const studentsLower = students.map(lowerCase);

console.log(studentsLower);

function upperCase(element){
return element.toUpperCase();
}

function lowerCase(element){
return element.toLowerCase();
}

// EXAMPLE 3
const dates = ["2024-1-10", "2025-2-20", "2026-3-30"];
const formattedDates = dates.map(formatDates);

console.log(formattedDates);

function formatDates(element){
const parts = element.split("-");
return
}

BroCodez
Автор

Hey Bro! you have a way of making me undertstand every topics that i've ever struggled with.

God bless you abundantly!!

seunopeyemi
Автор

bro i used to hate programming and computers in general.Also the tutorials always tested my patience . i litreally used to yawn in online tutorial. but after discovering you, tables turned !! i just joined collage and our first language is c program.i just discovered you and i forget i had to make notes i was just watching and doing ehat ypu were demonstrating . i finally know how to study this subjec and hass fallen in live with .THANKS A LOT 😇😇😇😇

amishbhaskar
Автор

This guy is the goat at teaching how to code

Chlorine-DB
Автор

Thank you so much! You're skilled with the gift of teaching.

LizyAd
Автор

bro code truly is a bro, you have just saved my ass, I couldnt understand where to get the parameters.

SaiTaX_the_Chile_boi
Автор

Now you are my favorite coding teacher 😅

vinzanity
Автор

Super easy to follow along with thanks!

ElevateCode
Автор

thanks to you i understood the map() method ! thank you again

mjylove
Автор

<*_> This is my seal. I have watched the entire video, understood it, and I can explain it in my own words, thus I have gained knowledge. This is my seal. <_*>

piotrmazgaj
Автор

I just love IT not YOU you know in the past vacances I just decouvered you and I always wanted to learn to code but I saw a video about python and I deractly begin coding (Sorry if my english is bad)
now I am in python and I really progress and cause of you I learned to be patience and to solve my errors.
Last thing to say
I LOVE YOUR CONTENT YOU ARE THE BEST

gamerkit
Автор

Thank you for your great work. I have a question.

Is it better to write:

const studentsUpper = students.map(element => element.toUpperCase())
console.log(studentsUpper);

instead of write a function? I've heard that the way I just wrote it more modern and even has a better readablitiy. Is it true? Of course unless we are gonna re-use it then I think a function is a better way.

Thanks again.

ahmedoo
Автор

@BroCodez can you do a Lua full course

ENDTIMSPRODUCTIONS
Автор

we'd like you to teach us React JS <333

soyeonpark
Автор

it shows the month and the date but the year says undefined am I doing something wrong?

Misterkennedy
Автор

0:01 No you don't gotta explain it 😭

CodeWithAbed
Автор

HI






















DABA DAB ADA DABA DAB AEI DAB AEI DABA EO FUSHCI SKITHCI CIHI

dhiyanabdurazack