Wpis z mikrobloga

#javascript #programowanie
Witam, pomoże ktoś, gdzie jest błąd, dopiero się uczę

function add(a,b,c) {
a = if (a === undefined || typeof a === "string") a=0;
b = if (b === undefined || typeof b === "string") b=0;
c = if (c === undefined || typeof c === "string") c=0;
console.log(a);
console.log(b);
console.log(c);
return a + b + c;
}
add(2,3,2);
  • 12
function add(a,b,c) {

a = if (a === undefined || typeof a === "string") a=0;

b = if (b === undefined || typeof b === "string") b=0;

c = if (c === undefined || typeof c === "string") c=0;

console.log(a);

console.log(b);

console.log(c);

return a + b + c;

}

add(2,3,2);


@qba111:

function add(a=0,b=0,c=0) {
console.log(a);
console.log(b);
console.log(c);
return a + b + c;
}
add(2,3,2);

elo