This code does not execute properly. Try to figure out why.
function multiply(a, b){
return a * b
}
We need a function that can transform a number (integer) into a string.
What ways of achieving this do you know?
123 --> "123"
999 --> "999"
-100 --> "-100"
function numberToString(num) {
return `${num}`
}
function numberToString(num) {
return num.toString();
}
function numberToString(num) {
// Return a string of the number here!
return String(num);
}
function numberToString(num) {
return ''+num;
}
The starship Enterprise has run into some problem when creating a
program to greet everyone as they come aboard. It is your job to fix the
code and get the program working again!
Example output:
Hello, Mr. Spock
function sayHello(name) {
return `Hello, ${name}`
}
const sayHello = name => `Hello, ${name}`;
Implement a function that accepts 3 integer values a, b, c. The function should
return true if a triangle can be built with the sides of given length
and false in any other case.
(In this case, all triangles must have surface greater than 0 to be accepted).
Examples:
Input -> Output
1,2,2 -> true
4,2,3 -> true
2,2,2 -> true
1,2,3 -> false
-5,1,3 -> false
0,2,3 -> false
1,2,9 -> false
function isTriangle(a,b,c)
{
// 삼각형 성립조건
// 가장 긴 변의 길이가 나머지 두 변의 길이의 합보다 작아야 함
// 가장 큰 값을 구하고 나머지 두 값을 더해서 비교
const arr = [a,b,c];
let value = 0;
arr.map((item) => {
return item > value ? value = item : value
})
return value +
}
function isTriangle(a, b, c) {
return (a + b > c) && (a + c > b) && (b + c > a);
}
function isTriangle(a, b, c) {
let arr = [a, b, c].sort();
return arr[2] < (arr[0] + arr[1]);
}
function isTriangle(a, b, c) {
let max = Math.max(a, b, c);
return max < (a + b + c - max);
}
function isTriangle(a, b, c) {
let max = Math.max(a, b, c);
return max < (a + b + c) / 2;
}