3.1 KiB
3.1 KiB
id, title, localeTitle, challengeType
id | title | localeTitle | challengeType |
---|---|---|---|
56533eb9ac21ba0edf2244d4 | Comparison with the Greater Than Operator | Comparación con el operador mayor que | 1 |
Description
>
) compara los valores de dos números. Si el número a la izquierda es mayor que el número a la derecha, devuelve true
. De lo contrario, devuelve false
.
Al igual que el operador de igualdad, el operador mayor que el convertirá los tipos de datos de valores al comparar.
ejemplos
5 > 3 // true
7 > '3' // true
2 > 3 // false
'1' > 9 // false
Instructions
greater than
a las líneas indicadas para que las declaraciones de devolución tengan sentido.
Tests
tests:
- text: <code>testGreaterThan(0)</code> debe devolver "10 o inferior"
testString: 'assert(testGreaterThan(0) === "10 or Under", "<code>testGreaterThan(0)</code> should return "10 or Under"");'
- text: <code>testGreaterThan(10)</code> debe devolver "10 o inferior"
testString: 'assert(testGreaterThan(10) === "10 or Under", "<code>testGreaterThan(10)</code> should return "10 or Under"");'
- text: <code>testGreaterThan(11)</code> debe devolver "Over 10"
testString: 'assert(testGreaterThan(11) === "Over 10", "<code>testGreaterThan(11)</code> should return "Over 10"");'
- text: <code>testGreaterThan(99)</code> debe devolver "Over 10"
testString: 'assert(testGreaterThan(99) === "Over 10", "<code>testGreaterThan(99)</code> should return "Over 10"");'
- text: <code>testGreaterThan(100)</code> debe devolver "Over 10"
testString: 'assert(testGreaterThan(100) === "Over 10", "<code>testGreaterThan(100)</code> should return "Over 10"");'
- text: <code>testGreaterThan(101)</code> debe devolver "Over 100"
testString: 'assert(testGreaterThan(101) === "Over 100", "<code>testGreaterThan(101)</code> should return "Over 100"");'
- text: <code>testGreaterThan(150)</code> debe devolver "Over 100"
testString: 'assert(testGreaterThan(150) === "Over 100", "<code>testGreaterThan(150)</code> should return "Over 100"");'
- text: Debes usar el operador <code>></code> al menos dos veces
testString: 'assert(code.match(/val\s*>\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>></code> operator at least twice");'
Challenge Seed
function testGreaterThan(val) {
if (val) { // Change this line
return "Over 100";
}
if (val) { // Change this line
return "Over 10";
}
return "10 or Under";
}
// Change this value to test
testGreaterThan(10);
Solution
function testGreaterThan(val) {
if (val > 100) { // Change this line
return "Over 100";
}
if (val > 10) { // Change this line
return "Over 10";
}
return "10 or Under";
}