摘要:
<script>function runSlots() {var slotOne;var slotTwo;var slotThree; var images = ["https://www.w3cschool.cn/statics/codecamp/images/9H17QFk.png", "htt 阅读全文
摘要:
var testString = "How many spaces are there in this sentence?"; var expression = /\s+/g; var spaceCount = testString.match(expression).length; 我们也可以使用 阅读全文
摘要:
var testString = "There are 3 cats but 4 dogs."; var expression = /\d+/g; var digitCount = testString.match(expression).length; //特殊选择器中的一种就是数字选择器\d,意 阅读全文
摘要:
var testString = "Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it."; var expression = /and/gi; 阅读全文
摘要:
function randomRange(myMin, myMax) { return Math.floor(Math.random()*(myMax - myMin + 1)) + myMin; } // 创建一个叫randomRange的函数,参数为myMin和myMax,返回一个在myMin( 阅读全文
摘要:
function myFunction() { var a =Math.floor(Math.random()*10);return a;} // 记住 Math.random() 永远不会返回 1。同时因为我们是在用 Math.floor() 向下取整,所以最终我们获得的结果不可能有 20。这确保 阅读全文
摘要:
function multiplyAll(arr) {var product = 1;//如果你有一个二维数组,可以使用嵌套循环的逻辑,先遍历外面的数组,再遍历里面的子数组 for(var i=0; i< arr.length; i++){ for(var j=0; j< arr[i].length 阅读全文