async function getArray() {
return new Promise((resolve) => {
setTimeout(() => {
resolve([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
}, 1000);
});
}
async function squareArray(arr) {
return arr.map(num => num * num);
}
async function filterGreaterThan100(arr) {
return arr.filter(num => num > 100);
}
async function main() {
try {
const arr = await getArray();
const squaredArr = await squareArray(arr);
const result = await filterGreaterThan100(squaredArr);
console.log(result);
} catch (error) {
console.error('发生错误:', error);
}
}
main();