Function getUser accepts userId and returns a Promise.
The functionality is missing and you need to fix that.
The promise should be rejected if the userId is missing. The promise should be resolved with the appropriate user object if the userId is provided....
Fill in the array fruits with 5 elements and export it from the file helper.js
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...
Programming should be fun! In this task, you鈥檒l learn how to add a randomized delay to the console.log statements in JavaScript and Node.js.
We鈥檒l start small.
In the file function.js you see an empty function log....
Now, we鈥檒l split the output into individual characters.
Each character should be printed separately using console.log
Also, let鈥檚 refactor the code and rename our function to splitLog
This task is part of the Full-Stack JavaScript Course....
The problem is that now each character is printed on a separate line.
We can fix this by replacing console.log with process.stdout.write.
As we still want the output to end with a newline character, print \n...
Great job! Now we鈥檒l start working on a delay.
Implement a sleep function and export it from the file helper.js
Here鈥檚 the spec:
sleep should return a Promise the Promise returned by sleep(ms) should be resolved in ms milliseconds This task is part of the Full-Stack JavaScript Course....
Let鈥檚 use the sleep function that you鈥檝e just implemented.
add a second parameter delay to the function writeLog sleep for delay milliseconds after printing each character don鈥檛 forget the async and `await keywords!...
The output will look even better if we randomize the timing.
Let鈥檚 add another boolean parameter randomized to the function writeLog.
If it鈥檚 true, then the argument passed into sleep...
Right now, we鈥檝e implemented pretty much everything we wanted to.
But calling it isn鈥檛 very clean as we have to pass the delay
and randomization flag every time we want to print something to the console....
You did a great job!
One more thing and we鈥檒l be good to go
Let鈥檚 add a default delay of 100ms to the funkylog.
So, if the field delay is missing from the config object, we set it to the default value....