locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
15 lines (14 loc) • 502 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.length = length;
function length(str) {
// parity verified: Ruby 3.3
// discuss at: https://locutus.io/ruby/String/length/
// original by: Kevin van Zonneveld (https://kvz.io)
// note 1: Returns the character length of str.
// example 1: length('hello')
// returns 1: 5
// example 2: length('')
// returns 2: 0
return (str + '').length;
}