Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
    <head><title>崗哨循序搜尋</title></head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body></body>
</html>
 
$().ready(function(){
    var datas=[8,4,1,3,9,5,6,7,2,0];
    var i=0;
    var found=false;
    var n=parseInt(window.prompt("請輸入要搜尋的數字"));
    datas.push(n);
    console.log(datas);
    while(datas[i]!=n){
        i++;
    }
    if(i<datas.length-1)window.alert("index「"+i+"」是要找的數字:"+n);
    else window.alert("找不到要找的數字"+n);
});
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
yaoyao34pro
0viewers