locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
17 lines (16 loc) • 621 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.end_with = end_with;
function end_with(str, suffix) {
// parity verified: Ruby 3.3
// discuss at: https://locutus.io/ruby/String/end_with/
// original by: Kevin van Zonneveld (https://kvz.io)
// note 1: Returns true if str ends with one of the suffixes given.
// example 1: end_with('hello', 'ello')
// returns 1: true
// example 2: end_with('hello', 'heaven')
// returns 2: false
str = str + '';
suffix = suffix + '';
return str.endsWith(suffix);
}