repeat
JavaScript string的repeat方法可以实现对一个字符串进行重复多次的功能。
语法:str.repeat(count)
count:重复的次数。是一个0到+Infinity之间的整数,表示要对原字符串进行重复的次数
返回值:一个重复原字符串count次的新字符串,不会改变原字符串
const str = 'hello'
str.repeat(0) // ''
str.repeat(1) // 'hello'
str.repeat(-1) // 报错 提示无效的count value
str.repeat(2) // 'hellohello'
str.repeat(2.5) // 'hellohello' 向下取整