The askTeller
function has been modified within the Person
class to directly give you your balance. However, it now needs the account password in order to return the bankBalance
.
JS Passing argument
上一篇 / 下一篇 2015-08-16 09:11:06 / 个人分类:JavaScript
TAG:
- 引用 删除 wilber.shinobi / 2015-08-16 11:40:31
-
Examine the languages object. Three properties are strings, whereas one is a number.
Use a for-in loop to print out the three ways to say hello. In the loop, you should check to see if the property value is a string so you don't accidentally print a number.
- 引用 删除 wilber.shinobi / 2015-08-16 11:40:00
-
Looks For-In To Me
Objects aren't so foreign if you really think about it!
Remember you can figure out the type of a variable by using typeof myVariable;. Types we are concerned with for now are "object", "string", and "number".
Recall the for-in loop:
for(var x in obj) {
executeSomething();
}
This will go through all the properties of obj one by one and assign the property name to x on each run of the loop.
Let's combine our knowledge of these two concepts.
Sample codes:
var languages = {
english: "Hello!",
french: "Bonjour!",
notALanguage: 4,
spanish: "Hola!"
};
// print hello in the 3 different languages
for ( var x in languages ) {
if ( (typeof languages[x]) === "number" ) {
continue; // to skip printing out the non string.
} else if ( (typeof languages[x]) === "string" ) {
console.log(languages[x]);
}
}
Results:
Hello!
Bonjour!
Hola!
标题搜索
日历
|
|||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
1 | 2 | 3 | 4 | 5 | 6 | ||||
7 | 8 | 9 | 10 | 11 | 12 | 13 | |||
14 | 15 | 16 | 17 | 18 | 19 | 20 | |||
21 | 22 | 23 | 24 | 25 | 26 | 27 | |||
28 | 29 | 30 |
我的存档
数据统计
- 访问量: 17069
- 日志数: 29
- 建立时间: 2012-02-03
- 更新时间: 2018-10-12