FCC - Confirm The Ending
Check if a string (first argument, str) ends with the given target string (second argument, target).
by Tom M
HTML
<div id="test">
</div>
JavaScript
function confirmEnding(str, target) {
var ending = target;
var regexp = new RegExp(ending + "$", "g");
//return regexp;
var x = regexp.test(str);
return x;
}
document.getElementById("test").innerHTML = confirmEnding("Bastian", "ian");;