让我们取一个单词=鸟我想要输出=
ibrd
我应该把它的位置改为开头。我可以使用JavaScript吗?我怎么能用绳子做这个。
我认为这将解决您的问题
const changeLetter = (val /* string value */, index /* index of the letter (i in this scenario)*/) => {
let temp = val.split('');
temp.splice(index, 1);
temp.unshift(val[index]);
return temp.join('');
}
const val = 'bird';
console.log(changeLetter(val, 1));