-
Notifications
You must be signed in to change notification settings - Fork 0
/
task-04.js
31 lines (26 loc) · 1.03 KB
/
task-04.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
"use strict";
const formatString = function(string) {
return string.length > 40 ? string.slice(0, 40) + "..." : string;
};
console.log(formatString("Curabitur ligula sapien, tincidunt non."));
console.log(formatString("Vestibulum facilisis, purus nec pulvinar iaculis."));
console.log(formatString("Curabitur ligula sapien."));
console.log(
formatString(
"Nunc sed turpis. Curabitur a felis in nunc fringilla tristique."
)
);
// ============= ВТОРОЙ ВАРИАНТ РЕШЕНИЯ
// const formatString = function(string) {
// if(string.length > 40){
// let editedText = string.slice(0,40) + '...';
// return editedText;
// }
// else{
// return string;
// }
// }
// console.log(formatString('Curabitur ligula sapien, tincidunt non.'));
// console.log(formatString('Vestibulum facilisis, purus nec pulvinar iaculis.'));
// console.log(formatString('Curabitur ligula sapien.'));
// console.log(formatString('Nunc sed turpis. Curabitur a felis in nunc fringilla tristique.', ),);