dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.1 KiB
1.1 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 6619240f46cec8e04d77e03a | Basic Functions Exercise A | 1 | top-basic-functions-exercise-a |
--description--
Create a function that takes in an integer. This function should return the given integer + 7 if the integer is less than 10. If the integer is greater than or equal to 10, it should return the given integer - 3.
The name of the function should be addOrSubtract.
--hints--
You should have a function called addOrSubtract.
assert.isFunction(addOrSubtract);
Your function should take in an integer as an argument.
assert.match(addOrSubtract.toString(), /\s*addOrSubtract\(\s*\w+\s*\)/);
You should return the given integer + 7 if the integer is less than 10.
assert.strictEqual(addOrSubtract(5), 12);
You should return the given integer - 3 if the integer is greater than or equal to 10.
assert.strictEqual(addOrSubtract(10), 7);
--seed--
--seed-contents--
--solutions--
function addOrSubtract(num) {
if (num < 10) {
return num + 7;
} else {
return num - 3;
}
}