trimRight() remove the spaces from right side of the string but this is not a standard function so don't use this function on live websites because this will not work for every user because of incompatibilities. See the code snippet:
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
<script>
var str = " Welcome to LearnKode ";
str = str.trimRight();
document.write(str); //' Welcome to LearnKode'
</script>
</body>
</html>