我不明白什么>> =意味着(我认为大于或等于> =)也是:(时间和1)从下面.
function repeat (string, times) {
var result = ''
while (times > 0) {
if (times & 1) result += string
times >>= 1
string += string
}
return result
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写javascript代码,测试第一个字符串的结尾是否与目标相同,返回true.否则,返回false.必须使用.substr()来获得结果.
function end(str, target) {
myArray = str.split();
//Test if end of string and the variables are the same
if (myArray.subsrt(-1) == target) {
return true;
}
else {
return false;
}
}
end('Bastian', 'n');
Run Code Online (Sandbox Code Playgroud)