For example, I only want to pass one value to the function and that the others are default values of the function:
const saludar = function(nombre='Visitante', edad=20, profesion='Desarrollador Web'){
return `Tienes ${edad}, eres ${profesion} y te llamas ${nombre}`;
}
console.log(saludar(edad=35));
And I want to just give it the variable edad=35
, so I want it to print:
Tienes 35, eres Desarrollador Web y te llamas Visitante
using destructuring assignment
Use only your parameter which is variable and declare the constants inside the function. example:
Code