• Агар Аллоҳ сўраганингни берса, сен иймонлисан!
• Агар сал кечиктириб берса, сабрлисан!
• Агар бермаса, сен ундан буюгига лойиқсан!
• Агар сал кечиктириб берса, сабрлисан!
• Агар бермаса, сен ундан буюгига лойиқсан!
💯3
function Animal(name, count, year) {
this.name = name;
this.count = count;
this.year = year;
}
const dog = new Animal("dog", 6, 3);
const cat = new Animal("Cat", 3, 2);
console.log(dog);
console.log(cat);const computer = {
model: "Asus Tuf Gaming A15",
price: "830$",
count: 3,
};
function getInfo(computer) {
return computer;
}
const s = getInfo(computer);
console.log(s);
// 2-usul
function Computer(model, price, count) {
this.model = model;
this.price = price;
this.count = count;
this.getInfo = function () {
return `Model: ${this.model} , Price: ${price} , Count: ${count}`;
};
}
const Asus = new Computer("Hp i513", "550$", 3);
console.log(Asus.getInfo());function Checkinteger(number) {
return number;
}
console.log(Number.isInteger(Checkinteger(5)));
console.log(Number.isInteger(Checkinteger(5.5)));function ChangeText(text, target, replacement) {
return text.split(target).join(replacement); // split qirqish join qo'shish
}
const natija = ChangeText("Assalomu alaykum", "al", "ok");
console.log(natija);function calculateArea(yuza) {
const area = this.length * this.width;
return yuza + " " + area;
}
const rectangle1 = { length: 5, width: 10 };
const rectangle2 = { length: 7, width: 3 };
const r = calculateArea.call(rectangle1, "yuza");
console.log(r);function calculateArea(yuza) {
const area = this.length * this.width;
return yuza + " " + area;
}
const rectangle1 = { length: 5, width: 10 };
const rectangle2 = { length: 7, width: 3 };
const r = calculateArea.apply(rectangle1, ["yuza"]);
console.log(r);function calculateArea(yuza) {
const area = this.length * this.width;
return yuza + " " + area;
}
const rectangle1 = { length: 5, width: 10 };
const rectangle2 = { length: 7, width: 3 };
const r = calculateArea.bind(rectangle1);
console.log(r("yuza"));function SplitText(text, split) {
return text.split(split);
}
const natija = SplitText("Learning JavaScript is fun!", " ");
console.log(natija);// 1
let mevalar = ["olma", "banan"];
mevalar.push("apelsin");
console.log(mevalar);
// 2
let ranglar = ["qizil", "yashil", "ko'k"];
let oxirgiRang = ranglar.pop();
console.log(oxirgiRang);
console.log(ranglar);
// 3
let avtomobillar = ["BMW", "Audi", "Mercedes"];
let birinchiAvto = avtomobillar.shift();
console.log(birinchiAvto); // "BMW"
console.log(avtomobillar);
// 4
let shaharlar = ["Toshkent", "Samarqand"];
let qishloqlar = ["Chirchiq", "Angren"];
let barchaJoylar = shaharlar.concat(qishloqlar);
console.log(barchaJoylar);
// 5
let yoshlar = [15, 18, 22, 17, 19];
let kattaYoshlar = yoshlar.filter((yosh) => yosh >= 18);
console.log(kattaYoshlar);
// 6
let sonlar = [2, 4, 6];
let kvadratlar = sonlar.map((son) => son * son);
console.log(kvadratlar);
// 1
let text2 = "Salom, Dunyo Salom";
console.log(text2.indexOf("Dunyo"));
console.log(text2.indexOf("Salom"));
console.log(text2.indexOf("Xayr")); // -1 (topilmasa -1 qaytaradi)
// 2
let text1 = "Salom, Dunyo Salom";
console.log(text1.lastIndexOf("Salom"));
console.log(text1.lastIndexOf("Dunyo"));
// 3
let text3 = "Salom, Dunyo";
console.log(text3.includes("Dunyo"));
console.log(text3.includes("Xayr"));
// 4
let text = "Salom, Dunyo Barcha";
let arr = text.split(", ");
console.log(arr);
// 5
let array = ["Salom", "Dunyo"];
console.log(array.join(" - "));
1👍1🔥1
This media is not supported in the widget
VIEW IN TELEGRAM
🔥4
function getHotelDetails() {
return new Promise((resolve) => {
setTimeout(() => {
resolve(
"Adress:Toshkent shahar chilonzor tumani, Qavat: 7ta, xonalar soni: 60ta, bo'sh xonalar soni: 10ta "
);
}, 2000);
});
}
function getFlightDetails() {
return new Promise((resolve) => {
setTimeout(() => {
resolve(
"Uchish joyi:Rossiya domodedevo Aeraporti, Uchish vaqti : 19:00 ,Yetib borish : 22:00 "
);
}, 2000);
});
}
function getWeatherDetails() {
return new Promise((resolve) => {
setTimeout(() => {
resolve(
"Rosiyya Toshkent yo'nalishi bo'yicha ob-havo ma'lumoti : 3 soatli parvoz vaqtida yomg'ir yoki qor yo'q havo ozgina sovuqroq 2'C dan 5'C gacha haroratda bo'ladi ! "
);
}, 2000);
});
}
getHotelDetails().then((data) => {
console.log(data);
}),
(err) => {
console.log(err);
};
getFlightDetails().then((data) => {
console.log(data);
}),
(err) => {
console.log(err);
};
getWeatherDetails().then((data) => {
console.log(data);
}),
(err) => {
console.log(err);
};👌2👍1🔥1
function getHotelDetails() {
return new Promise((resolve) => {
setTimeout(() => {
resolve(
"Adress:Toshkent shahar chilonzor tumani, Qavat: 7ta, xonalar soni: 60ta, bo'sh xonalar soni: 10ta "
);
}, 2000);
});
}
function getFlightDetails() {
return new Promise((resolve) => {
setTimeout(() => {
resolve(
"Uchish joyi:Rossiya domodedevo Aeraporti, Uchish vaqti : 19:00 ,Yetib borish : 22:00 "
);
}, 2000);
});
}
function getWeatherDetails() {
return new Promise((resolve) => {
setTimeout(() => {
resolve(
"Rosiyya Toshkent yo'nalishi bo'yicha ob-havo ma'lumoti : 3 soatli parvoz vaqtida yomg'ir yoki qor yo'q havo ozgina sovuqroq 2'C dan 5'C gacha haroratda bo'ladi ! "
);
}, 2000);
});
}
function bookTrip() {
Promise.all([getHotelDetails(), getFlightDetails(), getWeatherDetails()])
.then((data) => {
const [hotelData, flightData, weatherData] = data;
console.log("Mehmonxona ma'lumotlari olingan --->", hotelData);
console.log("Parvoz ma'lumotlari olingan --->", flightData);
console.log("Ob-havo ma'lumotlari olingan --->", weatherData);
})
.catch((error) => {
console.log("xato");
});
}
bookTrip();🔥3👌2👍1
const son = Math.trunc(Math.random() * 10);
const Mypromise = new Promise((yes, no) => {
setTimeout(() => {
if (son >= 5) {
yes(true);
} else {
no(false);
}
}, 3000);
});
Mypromise.then(
(data) => {
console.log(data);
},
(data) => {
console.log(data);
}
);
🔥3👌2👍1
function makeReservation(xona) {
return new Promise((res, rej) => {
if (xona) {
res("Buyurtma muvaffaqiyatli !");
} else {
rej("Kechirasiz, xonalar mavjud emas !");
}
});
}
makeReservation(true) // Argument sifatida true yozilsa buyurtma tasdiqlandi false yozilsa rad etildi !
.then((data) => {
console.log(data);
return "tasdiqlandi !";
})
.catch((error) => {
console.log(error);
return "rad etildi";
})
.then((data) => {
console.log(data);
})
.catch((error) => {
console.log(error);
});🔥4👌2👍1