+ 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());
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());
+ 1
Thanks
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());