Created
June 9, 2023 10:49
-
-
Save i-havr/deae1ca8874c01d0ccc1e396714af687 to your computer and use it in GitHub Desktop.
Функція повертає скорочений до заданої кількості символів рядок із трьома крапками у кінці.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const LIMIT = 30; | |
const endStringWithThreeDots = (str) => { | |
if (str.length <= LIMIT) { | |
return str; | |
} else { | |
const updatedString = str.slice(0, LIMIT - 3) + "..."; | |
return updatedString; | |
} | |
}; |
Serrin
commented
Jun 9, 2023
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment