Declarative Approach
<script>
alert(confirmEnd("Go was designed with parallel and concurrent processing in mind", "mind")); // true
alert(confirmEnd("Go was designed with parallel and concurrent processing in mind", "brain")); // false
alert(confirmEnd("Go was designed with parallel and concurrent processing in mind", "d")); // true
alert(confirmEnd("Go was designed with parallel and concurrent processing in mind", "D")); // false
function confirmEnd(str, target) {
return str.slice(str.length - target.length) === target;
}
</script>
Most Helpful This Week
Generate random password for form field on click using JavaScript
JavaScript example to change image on click
Using jQuery delete table row on click
JavaScript simple alert on Click
Write a function that splits an array into groups the length of size and returns them as a two-dimensional array
How to current URL, HOST and URL attributes using JavaScript or jQuery?