Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const warnaBerubah = async (color, gagal, berhasil) => {
- const delay = Math.floor(Math.random() * 4000) + 500;
- console.log(delay);
- setTimeout(() => {
- if (delay > 3000) {
- gagal('gagal');
- } else {
- document.body.style.backgroundColor = color;
- berhasil('berhasil');
- }
- }, delay,
- );
- };
- const perubahan = async () => {
- const gagal = (errorMessage) => {
- console.log(errorMessage);
- };
- const berhasil = (successMessage) => {
- console.log(successMessage);
- };
- try {
- await warnaBerubah('blue', gagal, berhasil);
- } catch (sa) {
- console.log(sa);
- }
- };
- perubahan();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement