Skip to content

Instantly share code, notes, and snippets.

@NevermindKT
Created May 13, 2025 15:14
Show Gist options
  • Save NevermindKT/baa55abe8a8abfc7bee7df2495d6b98a to your computer and use it in GitHub Desktop.
Save NevermindKT/baa55abe8a8abfc7bee7df2495d6b98a to your computer and use it in GitHub Desktop.
//----------------------------------------111 1
const comparaison = (a, b) => {
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
//-----------------------------------------222 3
const stringSum = (...numbers) => numbers.reduce((a, x) => a + x, 0).toString();
//-----------------------------------------333 4
const squareAndRectangle = (...args) => {
if (args.length === 1)
return args[0] * 4;
if (args.length === 2)
return (args[0] + args[1]) * 2;
}
//-----------------------------------------444 13
function calculate(a, b, sign) {
switch (sign) {
case '+':
return a + b;
case '-':
return a - b;
case '*':
return a * b;
case '/':
return a / b;
}
}
//------------------------------------------555 17
const sumAll = (...args) => args.reduce((a, x) => a + x, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment