Arguments Optional - Intermediate Algorithm Scripting - Free Code Camp

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

love your videos can't say enough about how helpful they all are !

guyarnav
Автор

Always come here when I'm stuck. I like your systematic approach. I think you can omit the != and === operator when checking if the argument is a number via the function but I guess it just makes things a bit clearer.
Keep up the great work. I'm afraid I will be coming back here.

julianstorm
Автор

Thanks for your work. I always learn something from you.

aaronargottelopez
Автор

Thanks, I always like your brute force method

azumahjoshuazilmayee
Автор

Thanks a lot for this. You seem to reply to every comment on your videos

pratiksasmal
Автор

Thanks for showing us your approach. Btw, are you a full time web developer, digital nomad? You're always in a different location!

ThreeCrowns
Автор

A little bit messy but here is my solution:

const arr = Array.from(arguments)

if(arr.length === 2){
if(typeof arr[0] === "number" && typeof arr[1] === "number") {
return arr[0] + arr[1]
} else {
return undefined
}
}

if(typeof arr[0] !== "number") {
return undefined
} else{
return function (y){
if(typeof y !== "number"){
return undefined
} else{
return arr[0] + y
}
}
}
}

halochant
Автор

Crawling in my skin.... These wounds they will not heal.. fear is how I fall... confusing what is real...

JD-hqkn
Автор

thanks i didn't know how to implement the second function.

function addTogether() {
let a=arguments[0];
if(arguments[1]){
=>{
return typeof argument == "number";
})){
return Object.values(arguments).reduce((sum, argument) => sum+argument, 0); }else{
return undefined;
}
}else if(typeof a == 'number'){
return function(num){
if(typeof num == 'number'){
return num+a;
}else{
return undefined;
}
}
}
}

falafel
join shbcf.ru