This file contains hidden or 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
| function isNumeric(n) { | |
| return !isNaN(parseFloat(n)) && isFinite(n) | |
| } | |
| function multiplyNumeric(obj) { | |
| for (var i in obj) { | |
| if (isNumeric(obj[i])) { | |
| obj[i] *= 2; | |
| } | |
| } |
This file contains hidden or 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
| function truncate(str, maxlength) { | |
| if (str.length > maxlength) { | |
| return str.slice(0, maxlength - 3) + '...'; | |
| } | |
| } |
This file contains hidden or 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
| function checkSpam(str) { | |
| var firstWord = 'viagra'; | |
| var secondWord = 'xxx'; | |
| var string = str.toLowerCase(); | |
| var result; | |
| if (checkTheWord(firstWord) || checkTheWord(secondWord)) { | |
| return true; | |
| } | |
| return false; |
This file contains hidden or 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
| function ucFirst(str) { | |
| // только пустая строка в логическом контексте даст false | |
| if (!str) return str; | |
| return str[0].toUpperCase() + str.slice(1); | |
| } |
This file contains hidden or 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
| function getDecimal(num) { | |
| var result; | |
| var initialNum = Math.abs(num); | |
| var roundedNum = Math.round(initialNum); | |
| if (roundedNum > initialNum) { | |
| result = roundedNum - initialNum - 1; | |
| result = Math.abs(result); | |
| result = +result.toFixed(10); | |
| } |
This file contains hidden or 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
| function isNumeric(n) { | |
| return !isNaN(parseFloat(n)) && isFinite(n); | |
| } |
NewerOlder