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 |
|---|---|---|---|
| 696655d24b614176d4c9b78b | Challenge 168: Scaled Image | 28 | challenge-168 |
--description--
Given a string representing the width and height of an image, and a number to scale the image, return the scaled width and height.
- The input string is in the format
"WxH". For example,"800x600". - The scale is a number to multiply the width and height by.
Return the scaled dimensions in the same "WxH" format.
--hints--
scaleImage("800x600", 2) should return "1600x1200".
assert.equal(scaleImage("800x600", 2), "1600x1200");
scaleImage("100x100", 10) should return "1000x1000".
assert.equal(scaleImage("100x100", 10), "1000x1000");
scaleImage("1024x768", 0.5) should return "512x384".
assert.equal(scaleImage("1024x768", 0.5), "512x384");
scaleImage("300x200", 1.5) should return "450x300".
assert.equal(scaleImage("300x200", 1.5), "450x300");
--seed--
--seed-contents--
function scaleImage(size, scale) {
return size;
}
--solutions--
function scaleImage(size, scale) {
const [width, height] = size.split("x").map(Number);
const newWidth = width * scale;
const newHeight = height * scale;
return `${newWidth}x${newHeight}`;
}