forked from vsb-vaj/template-lab-2024s-01
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task-strings.js
33 lines (27 loc) · 1.19 KB
/
task-strings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Check functions which could help you solve these tasks https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
// 1 =================================
// Write function to parameterize a string.
// Example:
// console.log(parametrize("Javascript is the best"));
// "javascript-is-the-best"
// Your code:
const parametrize = (input) => {
return input.toLowerCase().replaceAll(' ', '-');
};
// 2 =================================
// Write function that takes object and return sentence
// Example:
// giveSentenceForPerson({name: "Obi-wan", position: "Jedi", age: 40, location: "Starwars universe"})
// ➞ Hello Obi-wan from Starwars universe! It is nice to meet you! You look awesome for your 40, young Jedi!
// Your code:
const giveSentenceForPerson = (obj) => {
return `Hello ${obj["name"]} from ${obj["location"]}! It is nice to meet you! You look awesome for your 40, young ${obj["position"]}!`;
};
// 3 =================================
// Write function that takes string and replace all `a`, `e`, `i`, `o` with *
// Example:
// replace("Hello Javascript") ➞ "H*ll* J*v*scr*pt"
// Your code:
const replace = (input) => {
return input.replace(/[aeio]/g, '*');
};