UNPKG

@linkdotnet/stringoperations

Version:

Collection of string utilities. Edit-Distances, Search and Data structures. Offers for example trie, levenshtein distance.

18 lines (17 loc) 603 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isPalindrom = void 0; function isPalindrom(word, ignoreCase = false) { if (word.length === 0) { return false; } for (let i = 0; i < word.length / 2; i++) { const left = ignoreCase ? word.charAt(i).toUpperCase() : word.charAt(i); const right = ignoreCase ? word.charAt(word.length - 1 - i).toUpperCase() : word.charAt(word.length - 1 - i); if (left !== right) { return false; } } return true; } exports.isPalindrom = isPalindrom;