2.3 KiB
2.3 KiB
id | title | isRequired | challengeType | guideUrl | videoUrl | localeTitle |
---|---|---|---|---|---|---|
a97fd23d9b809dac9921074f | Arguments Optional | true | 5 | https://spanish.freecodecamp.org/guide/certificates/arguments-optional | Argumentos Opcionales |
Description
addTogether(2, 3)
debe devolver 5
y addTogether(2)
debe devolver una función. Llamar a esta función devuelta con un solo argumento devolverá la suma: var sumTwoAnd = addTogether(2);
sumTwoAnd(3)
devuelve 5
. Si cualquiera de los argumentos no es un número válido, devuelva indefinido. Recuerda usar Read-Search-Ask si te atascas. Trate de emparejar el programa. Escribe tu propio código. Instructions
Tests
tests:
- text: '<code>addTogether(2, 3)</code> debe devolver 5.'
testString: 'assert.deepEqual(addTogether(2, 3), 5, "<code>addTogether(2, 3)</code> should return 5.");'
- text: <code>addTogether(2)(3)</code> debe devolver 5.
testString: 'assert.deepEqual(addTogether(2)(3), 5, "<code>addTogether(2)(3)</code> should return 5.");'
- text: '<code>addTogether("http://bit.ly/IqT6zt")</code> debe devolver undefined.'
testString: 'assert.isUndefined(addTogether("http://bit.ly/IqT6zt"), "<code>addTogether("http://bit.ly/IqT6zt")</code> should return undefined.");'
- text: '<code>addTogether(2, "3")</code> debe devolver undefined.'
testString: 'assert.isUndefined(addTogether(2, "3"), "<code>addTogether(2, "3")</code> should return undefined.");'
- text: '<code>addTogether(2)([3])</code> debe devolver undefined.'
testString: 'assert.isUndefined(addTogether(2)([3]), "<code>addTogether(2)([3])</code> should return undefined.");'
Challenge Seed
function addTogether() {
return false;
}
addTogether(2,3);
Solution
// solution required