PP.endsWith

Syntax

endsWith(str: String, refStr: String);

Parameters

str. Base string.

refStr. Substring.

Description

The endsWith method determines whether the string ends with the specified substring.

Comments

This method returns True if the string ends with the specified substring, otherwise it returns False.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Determine substrings at the beginning and at the end of the Prognoz base string:

// Create a basic string
var baseStr = "Prognoz";
// Determine two substrings
var subStr1 = "noz";
var subStr2 = "Pro";
// Determine, at which substrings the basic string starts and ends
var isStarts = PP.startsWith(baseStr, subStr2) ? "starts" : "does not start";
console.log("The string «" + baseStr + "» " + isStarts + " with the substring «" + subStr2 + "».");
var isEnds = PP.endsWith(baseStr, subStr1) ? "ends" : "does not end";
console.log("The string «" + baseStr + "» " + isEnds + " with the substring «" + subStr1 + "».");

After executing the example the browser console displays information on the substrings at the beginning and at the end of the Prognoz base string:

The Prognoz string starts with Pro.

The Prognoz string ends with noz.

See also:

PP