@OmegaOrbitals2, If you change you code a bit, then you can do it like this where you have to use an object to input the parameters in any order.
function printLetters(values) {
// get values of a, b, and c, if they are null, use "1", "2", and "3"
let a = values.a || "1";
let b = values.b || "2";
let c = values.c || "3";
console.log(a);
console.log(b);
console.log(c);
}
printLetters({ c: "12" });
are you using javascript or typescript? because in regular javascript this shouldn’t give an error. Either way, this should work then.
function printLetters(values) {
// get values of a, b, and c, if they are null, use "1", "2", and "3"
let keys = Object.keys(values);
let a = keys.includes("a") ? values.a : "1";
let b = keys.includes("b") ? values.b : "2";
let c = keys.includes("c") ? values.c : "3";
console.log(a);
console.log(b);
console.log(c);
}
printLetters({ c: "12" });
That is the base Object class in javascript, you need it to call Object.keys() which gets all the keys in an object. So if you have { a: 4, b: 6, c: "hello"} then it would return ["a", "b", "c"]
How about you try this. Inside the defaults are all of your default values, the rest is handled and put into the values object. So to add any new ones, just add a new key to the defaults object.