我正在尝试解决一个在 codewars 上似乎很简单的 kata,但我似乎没有做对。
这个指令很简单,如下
给定两个整数的字符串表示,返回这些整数之和的字符串表示。
例如:
sumStrings('1','2') // => '3'
整数的字符串表示将不包含除“0”到“9”这十个数字之外的任何字符。
这就是我尝试过的
function sumStrings(a,b) {
return ((+a) + (+b)).toString();
}
Run Code Online (Sandbox Code Playgroud)
但结果解决了除两个之外的所有问题,这些是我得到的错误
sumStrings('712569312664357328695151392', '8100824045303269669937') - 预期:'712577413488402631964821329'74,而是 '574821329', got1204
sumStrings('50095301248058391139327916261', '81055900096023504197206408605') - 预期:'1311512013440818953248189532365'20009602365'2000960236518301836
我似乎不明白问题出在哪里。任何帮助都会有所帮助,谢谢。
我有这个script来从我的database
setInterval(function () {
$.ajax({
type: "GET",
url: "get_chat.php",
dataType: "html",
success: function (response) {
$(".msg_area").html(response);
}
});
}, 2000);
Run Code Online (Sandbox Code Playgroud)
我尝试在向其中添加新数据后立即为其添加声音,database但是当我添加到script上述内容时,它会播放audio每个2 seconds(我认为这是因为它在setInterval)
setInterval(function () {
$.ajax({
type: "GET",
url: "get_chat.php",
dataType: "html",
success: function (response) {
$(".msg_area").html(response);
var audio = new Audio('audio_file.mp3');
audio.play();
}
});
}, 2000);
Run Code Online (Sandbox Code Playgroud)
所以请我问。如何仅在新数据添加到数据库时播放声音?