<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="content-type" content="text/html; charset=UTF-8">
<title>对话框测试</title>
<script>
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];
function lookUp(firstName, prop){
// 请把你的代码写在这条注释以下
for(var i=0;i<contacts.length;i++){
if(contacts[i].firstName == firstName ){
}
}
// 请把你的代码写在这条注释以上
}
// 你可以修改这一行来测试你的代码
</script>
</head>
<body>
对话框测试:
<div style="margin-top:50px">
<input type="button" value="alert" onclick='lookUp("Akira", "likes")' />
<input type="button" value="alert" onclick='lookUp("Kristian", "lastName")' />
<input type="button" value="alert" onclick='lookUp("Sherlock", "likes")' />
<input type="button" value="alert" onclick='lookUp("Bob", "number")' />
<input type="button" value="alert" onclick='lookUp("Akira", "address")' />
</div>
</body>
</html>
问题网址:http://www.freecodecamp.cn/challenges/profile-lookup
答案网址:http://www.cnblogs.com/qimeng/p/6847985.html