Skip to content

Instantly share code, notes, and snippets.

@completejavascript
Last active April 30, 2019 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save completejavascript/f0912a7dd2cfc340272bd9261ba5e966 to your computer and use it in GitHub Desktop.
Save completejavascript/f0912a7dd2cfc340272bd9261ba5e966 to your computer and use it in GitHub Desktop.
const f1 = a => a;
const f2 = (a, b) => a + b;
const f3 = (a, b, c) => a + b + c;
const func = (type, ...params) => {
/* Hoàn thành hàm này */
}
func(1, 1); // -> 1 (1)
func(2, 1, 2); // -> 3 (1 + 2)
func(3, 1, 2, 3);// -> 6 (1 + 2 + 3)
/*
* Định dạng lại số thập phân 'number',
* với số lượng chữ số thập phân sau dấu phẩy tối đa là 'maxDecimal'
*/
const format = (number, maxDecimal) => {
/* Hoàn thành hàm này */
}
console.log(format(1, 2)); // => 1;
console.log(format(1.1, 2)); // => 1.1;
console.log(format(1.123, 2)); // => 1.12;
console.log(format(1.125, 2)); // => 1.13;
/*
* Convert mảng màu rgb thành hex
*/
const toHex = (r, g, b) => {
/* Hoàn thành hàm này */
}
console.log(toHex(0, 255, 255)); // => #00ffff
console.log(toHex(255, 0, 255)); // => #ff00ff
console.log(toHex(255, 255, 0)); // => #ffff00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment