Strings.skipLast()

Syntax

function skipLast(string: string, count: number): string

Skips the last count characters in the string and returns the rest.

Parameters
string

The string to take characters from.

count

The number of characters to skip over.

Example

import { Strings } from 'potence';

const string = '987654321';

Strings.skipLast(string, 5);  // -> "9876"

Remarks

If string is shorter than count, this function skips over the entire string and returns an empty string.

If count is negative, this function skips from the beginning of the string instead (see Strings.skip(), which provides the same functionality).

Contrast Strings.take(). Compare Strings.skipUntil().