Javascript String endsWith(c)

Description

Javascript String endsWith(c)


// $Id:$/*from   w  ww  .ja v  a2s.co  m*/

// Returns True if string ends with the provided character
String.prototype.endsWith = function(c)
    {
    return ( c == this.charAt(this.length-1));
    }

Javascript String endsWith(c)

/**/*from  ww  w . j  a  v  a  2  s.c o m*/
 * Created by Bunchhieng on 1/17/2016.
 */
String.prototype.endsWith = function(c) {
    return c === this.charAt(this.length - 1);
}

var message = "hello world";
console.log(message.endsWith('d'));
console.log(message.endsWith('a'));



PreviousNext

Related