chore: import upstream snapshot with attribution
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
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
This commit is contained in:
+61
@@ -0,0 +1,61 @@
|
||||
---
|
||||
id: 6619240f46cec8e04d77e03a
|
||||
title: Basic Functions Exercise A
|
||||
challengeType: 1
|
||||
dashedName: 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`.
|
||||
|
||||
```js
|
||||
assert.isFunction(addOrSubtract);
|
||||
```
|
||||
|
||||
Your function should take in an integer as an argument.
|
||||
|
||||
```js
|
||||
assert.match(addOrSubtract.toString(), /\s*addOrSubtract\(\s*\w+\s*\)/);
|
||||
```
|
||||
|
||||
You should return the given integer + 7 if the integer is less than 10.
|
||||
|
||||
```js
|
||||
assert.strictEqual(addOrSubtract(5), 12);
|
||||
```
|
||||
|
||||
You should return the given integer - 3 if the integer is greater than or equal to 10.
|
||||
|
||||
```js
|
||||
assert.strictEqual(addOrSubtract(10), 7);
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
function addOrSubtract(num) {
|
||||
if (num < 10) {
|
||||
return num + 7;
|
||||
} else {
|
||||
return num - 3;
|
||||
}
|
||||
}
|
||||
```
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
---
|
||||
id: 661e131f068359c3ccf2f4d6
|
||||
title: Basic Functions Exercise B
|
||||
challengeType: 1
|
||||
dashedName: top-basic-functions-exercise-b
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
Write a function, named `multiply`, that takes two parameters and returns their product.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have a function named `multiply`.
|
||||
|
||||
```js
|
||||
assert.isFunction(multiply);
|
||||
```
|
||||
|
||||
Your function should take in two integers as arguments.
|
||||
|
||||
```js
|
||||
assert.match(multiply.toString(), /\s*multiply\(\s*\w+\s*,\s*\w+\s*\)/);
|
||||
```
|
||||
|
||||
You should return the product of the two integers.
|
||||
|
||||
```js
|
||||
assert.strictEqual(multiply(10, 10), 100);
|
||||
```
|
||||
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
function multiply(a, b) {
|
||||
return a * b;
|
||||
}
|
||||
```
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
---
|
||||
id: 661e151f068359c3ccf2f4d7
|
||||
title: Basic Functions Exercise C
|
||||
challengeType: 1
|
||||
dashedName: top-basic-functions-exercise-c
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
Write a function, named `capitalize`, that takes a string as an parameter and returns a new string with the first letter capitalized.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have a function named `capitalize`.
|
||||
|
||||
```js
|
||||
assert.isFunction(capitalize);
|
||||
```
|
||||
|
||||
Your function should take in a string as a parameter.
|
||||
|
||||
```js
|
||||
assert.match(capitalize.toString(), /\s*capitalize\(\s*\w+\s*\)/);
|
||||
```
|
||||
|
||||
Your function should return a new string with the first letter capitalized.
|
||||
|
||||
```js
|
||||
assert.strictEqual(capitalize('sem'), 'Sem');
|
||||
```
|
||||
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
function capitalize(str) {
|
||||
return str[0].toUpperCase() + str.slice(1);
|
||||
}
|
||||
```
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
---
|
||||
id: 661e17c6068359c3ccf2f4d8
|
||||
title: Basic Functions Exercise D
|
||||
challengeType: 1
|
||||
dashedName: top-basic-functions-exercise-d
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
Write a function, named `lastLetter`, that takes a string as a parameter and returns the last letter of the string.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have a function named `lastLetter`.
|
||||
|
||||
```js
|
||||
assert.isFunction(lastLetter);
|
||||
```
|
||||
|
||||
Your function should take in a string as a parameter.
|
||||
|
||||
```js
|
||||
assert.match(lastLetter.toString(), /\s*lastLetter\(\s*\w+\s*\)/);
|
||||
```
|
||||
|
||||
You should return the last letter of the string.
|
||||
|
||||
```js
|
||||
assert.strictEqual(lastLetter('Sem'), 'm');
|
||||
```
|
||||
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
function lastLetter(str) {
|
||||
return str[str.length - 1];
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user