我首先尝试创建一个构造函数,以便我可以一次又一次地使用它然后我想打印出所有人的信息,但我无法完成此代码,任何人都可以帮助我,请写下你的想法过程谢谢!!
function profession(name, skill, year) {
this.name = name;
this.skill = skill;
this.years = years;
}
var Shen = new profession("Shen", "Javascript, nodejs", "0.3");
var Allen = new profession("Allen", "C, python", "20");
var Amy = new profession("Amy", "PHP, ruby", "3");
var jobHunting = [shen, Allen, Amy];
function list(person) {
document.write("The expert is: " + person.name + " his skill is " + person.skill + " with " + person.year + " years experience.");
}
function findAll() {
for (var i = 0; i < jobHunting.length; i++) {
list(jobHunting[i]);
}
}
答案 0 :(得分:0)
有一些拼写错误。
function profession(name, skill, years) {
this.name = name;
this.skill = skill;
this.years = years;
}
var Shen = new profession("Shen", "Javascript, nodejs", "0.3");
var Allen = new profession("Allen", "C, python", "20");
var Amy = new profession("Amy", "PHP, ruby", "3");
var jobHunting = [Shen, Allen, Amy];
function list(person) {
console.log("The expert is: " + person.name + " his skill is " + person.skill + " with " + person.year + " years experience.");
}
function findAll() {
for (var i = 0; i < jobHunting.length; i++) {
list(jobHunting[i]);
}
}
findAll() {
for (var i = 0; i < jobHunting.length; i++) {
list(jobHunting[i]);
}
}