JavaScript map() method in 7 minutes! 🗺

  Рет қаралды 22,029

Bro Code

Bro Code

Күн бұрын

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];
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 `${parts[1]}/${parts[2]}/${parts[0]}`;
}

Пікірлер: 22
@BroCodez
@BroCodez 8 ай бұрын
// .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 `${parts[1]}/${parts[2]}/${parts[0]}`; }
@user-mk2md9pu5m
@user-mk2md9pu5m 6 ай бұрын
Do django course please
@Spiritofprophecy112
@Spiritofprophecy112 6 ай бұрын
do a Lua full course
@amishbhaskar3264
@amishbhaskar3264 6 ай бұрын
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 😇😇😇😇
@samueldayo9261
@samueldayo9261 4 ай бұрын
C has similarities as JavaScript
@seunopeyemi8120
@seunopeyemi8120 2 ай бұрын
Hey Bro! you have a way of making me undertstand every topics that i've ever struggled with. God bless you abundantly!!
@SaiTaX_the_Chile_boi
@SaiTaX_the_Chile_boi 8 күн бұрын
bro code truly is a bro, you have just saved my ass, I couldnt understand where to get the parameters.
@LizyAd
@LizyAd 2 ай бұрын
Thank you so much! You're skilled with the gift of teaching.
@squidwardthemathematician
@squidwardthemathematician 6 ай бұрын
Thank you. I discovered a small mistake I made, so thanks to your video, I fixed it.
@Chlorine-DB
@Chlorine-DB 4 ай бұрын
This guy is the goat at teaching how to code
@mjylove2
@mjylove2 2 ай бұрын
thanks to you i understood the map() method ! thank you again
@nexezff4257
@nexezff4257 5 ай бұрын
thank you man
@jadronaldo566
@jadronaldo566 6 ай бұрын
thank you bro!
@DanTheCoder
@DanTheCoder 3 ай бұрын
That last example was so helpful
@Spiritofprophecy112
@Spiritofprophecy112 6 ай бұрын
@BroCodez can you do a Lua full course
@vinzanity68
@vinzanity68 3 ай бұрын
Now you are my favorite coding teacher 😅
@gamerkit2031
@gamerkit2031 6 ай бұрын
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
@tavidev
@tavidev 6 ай бұрын
TypeScript full course when?
@user-mk2md9pu5m
@user-mk2md9pu5m 6 ай бұрын
Do django course please
@arunbalakrishnan8978
@arunbalakrishnan8978 10 күн бұрын
So simple....
@AsahiLume
@AsahiLume 6 ай бұрын
mans quick
JavaScript filter() method in 6 minutes! 🚰
6:30
Bro Code
Рет қаралды 11 М.
JavaScript forEach() method in 8 minutes! ➿
8:02
Bro Code
Рет қаралды 21 М.
Indian sharing by Secret Vlog #shorts
00:13
Secret Vlog
Рет қаралды 58 МЛН
Pray For Palestine 😢🇵🇸|
00:23
Ak Ultra
Рет қаралды 34 МЛН
JavaScript reduce() method in 5 minutes! ♻
5:31
Bro Code
Рет қаралды 16 М.
Learn JavaScript CALLBACKS in 7 minutes! 🤙
7:17
Bro Code
Рет қаралды 32 М.
map Array Method | JavaScript Tutorial
6:49
Florin Pop
Рет қаралды 84 М.
Maps vs. Objects in JavaScript - What's the Difference?
11:48
Use Maps more and Objects less
5:45
Steve (Builder.io)
Рет қаралды 85 М.
forEach Array Method | JavaScript Tutorial
5:03
Florin Pop
Рет қаралды 219 М.
Map, Filter & Reduce EXPLAINED in JavaScript - It's EASY!
11:23
Indian sharing by Secret Vlog #shorts
00:13
Secret Vlog
Рет қаралды 58 МЛН