Hi there, I am usure of what I am doing wrong, when I run my code it seems ok, I get the userId back however, I do not pass the test "3. getUser should find the user by id and resolve the Promise with it"
import { loadData } from './storage.js';
export const getUser = (userId) => new Promise((resolve, reject) => {
//check userId and reject if it's missing
if (!userId) {
reject(new Error('user ID is missing'));
} else {
setTimeout(() => {
//use loadData and resolve with the user object if the id is present
let users = loadData;
let i;
if (userId === true && userId === users[i].id) {
userId = users[i];
return Promise.all(loadData.map(users[i]))
}
resolve(userId);
return {};
}, 200);
}
});