+ 1

JavaScript code proplem

whats wrong with this code..can some one helpe me? ...................... function estudent(name,degree){ this.name=name; this.age=age; this.degree=degree; this.Test= function(degree){ if (degree > 50){ return("faile"); } else{return("succeeded"); } } var es1=new estudent("omnia",60); document.write(es1.Test());

13th Jun 2020, 5:00 PM
omnia Gomaa
omnia Gomaa - avatar
3 Réponses
+ 1
Two changes: function estudent(name, degree){ this.name=name; //this.age=age; this.degree=degree; this.Test= function(){ if (this.degree > 50){ return("faile"); } else {return("succeeded"); } } } var es1=new estudent("omnia",60); document.write(es1.Test());
13th Jun 2020, 5:17 PM
JaScript
JaScript - avatar
+ 1
Thanks
13th Jun 2020, 7:18 PM
omnia Gomaa
omnia Gomaa - avatar
0
There is no age given in the parameters list. Please check, if this is sufficient to fix. There's additionally parameter mess with the method: function estudent(name, degree, age) { this.name = name; this.age = age; this.degree = degree; this.test = function() { if (degree > 50) { return("faile"); } else { return("succeeded"); } } } var es1 = new estudent("omnia", 60, 25); document.write(es1.test());
13th Jun 2020, 5:06 PM
Sandra Meyer
Sandra Meyer - avatar