Project 21: Music Player UI
JS Wizard
Builds on these lessons
Step 1 of 4
Project
Creating a Promise
Wrap a simulated track lookup in new Promise((resolve, reject) => {...}), resolving with track data after a delay. A Promise represents a value that isn't ready yet but will be — .then() runs once it resolves.
🎯 Your Task
Please add the exact code shown in the light gray box below to your editor.Do not delete your previous code, just insert these new lines in the correct place!
function loadTrack(trackId) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve({ id: trackId, title: "Horizon" });
}, 500);
});
}
loadTrack(1).then((track) => console.log(track));