📚 Rest JavaScript Interview: Mastering the Rest Operator Challenge #coding #codewithkg

preview_player
Показать описание
Unlock the secrets of the Rest Operator in JavaScript and ace your interviews! Watch this short to master the concept quickly and efficiently. 🚀
Рекомендации по теме
Комментарии
Автор

You need to pass an array as argument in function call or define rest parameter at function declaration.

rambattena
Автор

Excellent. Please do more videos like this

ssdheeraj
Автор

function sumNumber(...numbers) {
return numbers.reduce( (acc, curr) => acc + curr)
}
console.log(sumNumber(1, 2, 3, 4, 5))
output 15

saitejabommali
Автор

Hi sir,

function sum(...numbers){
return numbers.reduce((total, ele)=>{ return total+=ele});

Console.log(sum(1, 2, 3, 4, 5))

o/p : 15

sairamkaviti
Автор

Use rest operator in function sumnumbers, so that it can receive multiple arguments into a number which is an array and reduce is used to return a single element from an array . So finally answer is 15

Kiranruthala
Автор

use numbers argument with rest operator and the output will be 15.

rajesht
Автор

For reduce() we need to pass the initial value of the accumulator as the second argument after the calculation function, else the initial value of the accumulator will be undefined

Venkateswarlu
Автор

function(... numbers){

}
Rest in function parameters
Output =15

kria
Автор

It will give you typeError saying numbers.reduce is not a function. When we use rest operator along with the function parameter numbers, then output would be sum of numbers 15

RaviShankar-xyzh
Автор

Sir, please make a video on which companies pay best packages for freshers with javascript, frontend and backend. What should be the steps to get best packages with javascript, typescript, react, node and DB

sumanthkadiyam
Автор

Need to add ....number
It will return 10 as output

santhoshgoud
Автор

The error is you are not passing as array and the output is sum of array elements

P.Shivakrishna
Автор

Sir startups lo ekkuvaga eeh tech stack use chestharu...

b.rohit-
visit shbcf.ru