考核内容:javascript中String字符串的新特性repeat函数的使用
题发散度: ★★ ★
试题难度: ★
解题思路:
字符串的新增方法
repeat方法
返回一个新字符串,表示将原字符串重复n次。
'x'.repeat(3) // "xxx"'hello'.repeat(2) // "hellohello"'na'.repeat(0) // ""
repeat方法不会影响目标字符串。
参考代码:
答案:
B、repeat函数将目标字符串重复N次,目标字符串被修改