من المفترض ان ال live server يقوم بعمل مجلد المشروع الذى تقف فيه الى سيرفر ومن المفترض ايضا ان يستدعى ملفات الجافاسكريبت بشكل طبيعى .
ان الكود الذى قمت بارفاقه يوجد فيه بعض الاخطاء لهذا لا عمل جيدا . وقد قمت بتعديل الاخطاء لك . اذا لم يعمل هل يمكنك ارسال صورة لل console لديك . حتى ارى ما هى الاخطاء الموجودة .
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
// get age() {
// return this._age;
// }
hellow() {
console.log(
`Hello , My name is ${this.name} , and I am ${this.age} years old`
)
}
}
class Student extends Person {
constructor(name, age, level) {
super(name, age);
this.level = level;
}
}
const person = new Person('Ibrahim', 26);
person.hellow();
// try and catch
try {
alert('try');
} catch (error) {
alert('catch');
}
function area(width, height) {
if (isNaN(width) || isNaN(height)) {
throw Error('Parameter is a number');
}
return width * height;
}
const wait = time => new Promise(
(resolve, reject) => {
if (time > 5000) reject('Sory I can \ t wait');
setTimeout(resolve, time)
}
);
wait(2000)
.then(() => {
console.log("hello");
return wait(1000);
})
.then(() => {
console.log('world !');
});
new Promise((resolve, reject) => {
setTimeout(() => resolve(1), 1000);
})
.then(result => {
console.log(result);
return result * 2;
});