Write a JavaScript program to rotate the string in right direction by periodically removing one letter from the end of the string and attaching it to the front.
Here is my code:
<script>
function rotate() {
var string = "sentence";
var splitted = string.split("");
var newarr = [];
for (var i=splitted.length; i=0; i--) {
newarr = splitted.pop();
}
return newarr;
}
console.log (rotate());
</script>
Am I doing anything wrong in the logic of the For loop?
Thank you