Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Confirm the Ending

// Confirm the Ending

// Check if a string (first argument, str) ends with the given target string (second argument, target).
// This challenge can be solved with the .endsWith() method, which was introduced in ES2015.
// But for the purpose of this challenge, we would like you to use one of the JavaScript substring methods instead.
function confirmEnding(str, target) {
	let endOfStr = str.slice(str.length - target.length);

	return endOfStr === target;
}

confirmEnding('Bastian', 'an');

// OR

function confirmEnding(str, target) {
	return str.slice(-target.length) === target;
}

confirmEnding('Bastian', 'n');
Comment

PREVIOUS NEXT
Code Example
Javascript :: order array of objects by id javascript 
Javascript :: javascript join 
Javascript :: Send Email using AWS SES and Lambda 
Javascript :: union of two objects javascript 
Javascript :: how to delete a cookie in js 
Javascript :: chamar arquivo javascript no html 
Javascript :: jquery get element innertext 
Javascript :: discord.js how to edit a message 
Javascript :: jquery await async 
Javascript :: javascripte list length 
Javascript :: javascript get boolean if checkbox is checked 
Javascript :: javascript detect if element is scrolled 
Javascript :: delete from array based on value javascript 
Javascript :: how to align text vertically center beside an image in react native 
Javascript :: javascript date time formating 
Javascript :: nginx redirect location to port 
Javascript :: node js variables in string 
Javascript :: react fetch url 
Javascript :: radio button onclick jquery 
Javascript :: convert moment info to dd mmm yyyy 
Javascript :: getx arguments 
Javascript :: jquery selector this and class 
Javascript :: regex one or more words 
Javascript :: perform database transaction with sequelize 
Javascript :: hasownproperty 
Javascript :: mongoose findbyidandupdate return updated 
Javascript :: touppercase 
Javascript :: js array fill map 
Javascript :: javascript check typeof array 
Javascript :: jquery focus 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =