1. 程式人生 > >3377加減乘除等於24(原生js實現)

3377加減乘除等於24(原生js實現)

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無標題文件</title>
</head>

<body>
</body>
</html>
<script>
    //3377加減乘除 = 24 
        
//    3+""+3+""+7+""+7 == 24
    var fh = ["+","-","*","/","%"];
        for(var i = 0; i<fh.length; i
++){ for(var j = 0 ; j<fh.length; j++){ for(var k = 0 ; k<fh.length; k++){ if(eval(3+fh[i]+3+fh[i]+7+fh[i]+7) == 20){ console.log(3+fh[i]+3+fh[i]+7+fh[i]+7 +"=24"); console.log(i); } } } }
</script>