Fix the function printUserCount
.
Right now it prints to the console the string Promise { <pending> }
, but it should print the number of users.
This task is part of the Full-Stack JavaScript Course
If you have any issues with it, you can ask for community help below the post
Feel free to help others if you’ve already solved the task
db.js
const db = {
users: [
{
id: 1,
name: 'Jack',
friends: [ 23, 125 ],
}, {
id: 23,
name: 'Jane',
friends: [ 125 ],
}, {
id: 125,
name: 'Jill',
friends: [ 1 ],
}
]
}
export const getUserCount = () => new Promise((resolve, reject) => {
setTimeout(() => resolve(db.users.length), 200);
});
functions.js
import { getUserCount } from './db.js';
export const printUserCount = () => {
console.log(getUserCount());
}
solution.js
import { printUserCount } from './functions.js';
printUserCount();