创建一个javascript函数,该函数以一种方式返回字符串数组,使其顺序一次包含一个输入字符串的所有可能的大写字母。
uppercase("hello") ➞ ["Hello", "hEllo", "heLlo", "helLo", "hellO"]
我试过的是
const helloCapital = (str) => {
let a = [];
for (let i in str) {
a.push(str[i].toUpperCase() + str.slice(1));
}
return a;
};
但结果却很奇怪
[ 'Hello', 'Eello', 'Lello', 'Lello', 'Oello' ]