JavaScript map, arrow functions & ternary operator: JS Code Battle Tutorials

preview_player
Показать описание
Today we study the JavaScript array map method, the arrow function syntax and the ternary operator while watching Leonard and Radu battle each other in the first edition of the JS Code Battle Tutorials.

⭐️HackeRacer⭐️

⭐️More Funny Coding⭐️
Рекомендации по теме
Комментарии
Автор

Do you use any of these? Which one is your favorite? :-)

Radu
Автор

Best youtube channel for programming !!!

abdulbasitsaeed
Автор

Haha, I am going to code with Radu from now on!
Here is my answer:
const isOdd = (x) => x % 2;
const double = (x) => x * 2;
const half = (x) => x / 2;
const iif = (cond, x, y) => (num) => (cond(num) ? x(num) : y(num));

const oddDoubleEvenHalf = iif(isOdd, double, half);

function halfDouble(input) {
if (!input || !input.length) {
throw Error("input invalid");
}

return input.map(oddDoubleEvenHalf);
}

Zhentian-wan
Автор

This was both informative and hilarious, thanks 👍

riotsquirrelz
Автор

I'm amazed, didn't knew that i could use % to return a boolean. I hope to be as good as you someday :)

MrJackferson
Автор

i dont usually use map function but its absolutely useful🙂

unknown-bxmy
Автор

You are just amazing man!!
I am planning to cover everything which is there on your channel!!! A big fan!

ketan.pkapale
Автор

Haha nice little tutorial! I've been seeing the map method and arrow function recently and I've started to use them as well. I'm not the biggest fan of reading code with ternary operators, it's somehow not intuitive for me. So, that's something I need to start using more!

P.S. This is Jimi

Suzza
Автор

I always like your !BB videos. This one is very interesting too. Make more such things

laharisengupta
Автор

Both are good for me. Still, I use arrow functions and map method most of the time :)

nancyfazal
Автор

WHERE DO YOU COME UP WITH THIS ORIGINAL IDEAS? love it thanks haha

jakobmusic
Автор

Radu we want leonard orignal YTchannel , please tell us!!😕♥️♥️♥️♥️

rishabhgautam
Автор

/* I used the imperative way of programming but I will try to make it better*/

function myArr(arr){
let newArr = [];
for (let i = 0; i < arr.length; i++){
if (arr[i] % 2 === 1){
arr[i] = arr[i] * 2;
} else if (arr[i] % 2 === 0){
arr[i] = arr[i] / 2;
}
newArr.push(arr[i]);
}
return newArr;
}
let result = myArr;
console.log(result([2, 3, 8, 6, 1]));

saltech
join shbcf.ru