Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Write function rightchange(char, n) with JS to realize the cyclic right shift of character string char by n bits. Rightchange("abcdefg ",2) returns" fgabcde ".
Write function rightchange(char, n) with JS to realize the cyclic right shift of character string char by n bits. Rightchange("abcdefg ",2) returns" fgabcde ".
& ltscript type = " text/JavaScript " & gt;

Function rightchange(char, n)

{

Returns char.substr (char.length-n)+char.substr (0, char.length-n-1);

}

//used for demonstration

alert(rightchange("abcdefg ",2));

& lt/script & gt;