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.3 KiB
1.3 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 69cfca90e8a0a6d4d6871c51 | Challenge 267: Parsec Converter | 28 | challenge-267 |
--description--
In a distant galaxy, parsecs are used to measure both time and distance. Given an integer number of parsecs, return its equivalent in time or distance.
- If the given integer is odd, it represents time. If it's even, it represents distance.
Use these conversion rates:
| Parsecs | Time/Distance |
|---|---|
| 1 | 2 hours |
| 2 | 6 light years |
Return the converted value as an integer.
--hints--
convertParsecs(1) should return 2.
assert.equal(convertParsecs(1), 2);
convertParsecs(2) should return 6.
assert.equal(convertParsecs(2), 6);
convertParsecs(31) should return 62.
assert.equal(convertParsecs(31), 62);
convertParsecs(88) should return 264.
assert.equal(convertParsecs(88), 264);
convertParsecs(17) should return 34.
assert.equal(convertParsecs(17), 34);
convertParsecs(14) should return 42.
assert.equal(convertParsecs(14), 42);
--seed--
--seed-contents--
function convertParsecs(parsecs) {
return parsecs;
}
--solutions--
function convertParsecs(parsecs) {
if (parsecs % 2 !== 0) {
return parsecs * 2;
} else {
return parsecs * 3;
}
}