DEV Community

Mark Matthew Vergara
Mark Matthew Vergara

Posted on • Updated on

Javascript Tagalog - String endsWith Method

Ano ngaba ang String endsWith Method sa Javascript?
yung endsWith method sa javascript ay mag rereturn ng Boolean Value (true or false) depende if yung string is nag e-end sa binigay mong string as an argument

Pano gamitin:
First Argument
yung first argument ay yung string na gusto mo tignan if

x = 'mm vergara'

console.log( x.endsWith('vergara') ) // TRUE

console.log( x.endsWith('ara') ) // TRUE

console.log( x.endsWith('mm') ) // FALSE

Enter fullscreen mode Exit fullscreen mode

Second Argument (optional)
yung second argument is mag dedetermine kung ano length ng string mo, by default yung length is yung length ng string mo (in this ex. is 10).

  • if gusto mo i cut yung string babaan mo yung length using the 2nd argument. tignan monalang pics para magets mo.
//lenght of string is 10
x = 'mm vergara'

// Searching sa "mm vergara"
console.log( x.endsWith('vergara') ) // TRUE

// Searching sa "mm vergar"
console.log( x.endsWith('vergara',9) ) // False

// Searching as "mm verg"
console.log( x.endsWith('vergara',7) ) // False
Enter fullscreen mode Exit fullscreen mode

More tagalog Javascript Learning Resources:
https://javascript-methods-in-tagalog.vercel.app/

Top comments (0)