![]() |
#2
cho12018-01-11 16:20
console.log('welcome to your contacts manager');
var options = ["1: List contacts","0: Quit"]; console.log(options[0]); console.log(options[1]); function enter_your_option() { number = Number(prompt("enter your option! 1 or 0")); if(number == 1) { console.log("here is the list of all your contacts:"); var Contact = { init: function (lastname,firstname) { this.lastname = lastname; this.firstname = firstname; }, describe: function () { var description = "lastName: " + this.lastname + "," + "fristname: " + this.firstname + ","; return description; } }; var contact1 = Object.create(Contact); contact1.init("Smith","john"); var contact2 = Object.create(Contact); contact2.init("doe","jane"); var contacts = []; contacts.push(contact1); contacts.push(contact2); contacts.forEach(function (contact) { console.log(contact.describe()); }); enter_your_option(); } else if(number == 0){ console.log("end of contact manager!"); } } enter_your_option(); |
只有本站会员才能查看附件,请 登录