小编Gab*_*bro的帖子

确认不起作用

我需要在我的数组中推送新对象.每个对象都包含属性(名称,sName,年龄,职业和show方法,它们显示所有用户信息).数组由用户填写.(提示)但是确认有问题.当我推'取消'它仍然继续工作.这是我的代码.

   var staff = [];


   var askAgain = true;


    while(askAgain==true) {


      var employee = {
      name: prompt("enter the name of the  employee"), 
      sName: prompt("enter the sName of the employee"), 
      age: prompt("enter the age of the  employee"), 
      occupation: prompt("enter the occupation of the  employee"),
      show: function(){

        document.write(' employee:  ' + staff[1].name + ' ' + staff[1].sName + ', ' + staff[1].age + ', ' + staff[1].occupation + ' <br> ' );} }


      staff.push(employee);



     console.log(staff);



    window.confirm( "Would you like to go again?" …
Run Code Online (Sandbox Code Playgroud)

javascript

2
推荐指数
1
解决办法
45
查看次数

标签 统计

javascript ×1