Basic JavaScript 101
91-Iterate Through an Array with a For Loop
// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;
for (var i = 0; i < ourArr.length; i++) {
ourTotal += ourArr[i];
}
// Setup
var myArr = [ 2, 3, 4, 5, 6];
var total = 0;
for (i=0; i<myArr.length; i++){
total += myArr[i];
}
// Only change code below this line92-Nesting For Loops
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i<arr.length; i++){
for (var j=0; j<arr[i].length; j++){
product = product * arr[i][j];
}
}
// Only change code above this line
return product;
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);93-Iterate with JavaScript While Loops
94-Profile Lookup
要自幹一個資料查詢系統
可惜自己寫出來的不是最佳解 QQ
為什麼不 dot
討論區的解答
95-Generate Random Fractions with JavaScript
96-Generate Random Whole Numbers with JavaScript
97-Generate Random Whole Numbers within a Range
98-Sift through Text with Regular Expressions
/ for 正則表達式的開頭與結尾
g for global,搜尋全部字串
i for ignore,好像是忽略大小寫
99-Find Numbers with Regular Expressions
\d 代表數字
testString.match(expression) 會返回一個陣列
100-Find Whitespace with Regular Expressions
\s to find whitespace in a string.
\r (the carriage return) 回車
\n (newline) 換行
\t (tab)
\f (the form feed). 跳頁
101-Invert Regular Expression Matches with JavaScript
\S 單一字母
\S+ 列出全部單字
中文版的同場加映 Give your JavaScript Slot Machine some Stylish Images
角子老虎機

Last updated
Was this helpful?