JavaScript Promises

const checkInventory = (order) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
const itemsArr = order.items;
let inStock = itemsArr.every(item => store[item[0].inventory >= item[1]);

       if(inStock) {
         let total = 0;
         itemsArr.forEach(item => {
            total += item[1] * store[item[0]].cost

});
console.log(All of the items are in stock. The total cost of the order is ${total}.);
resolve([order, total]);
} else {
reject(The order could not be completed because some items are sold out.);
}, generateRandomDelay());
}); };
const processPayment = (responseArray) => {
const order = responseArray[0];
const total = responseArray[1];
return new Promise ((resolve,reject) => {
setTimeout( () => {
let hasEnoughMoney = order.giftcardBalance >= total;

  if(hasEnoughMoney) {
     console.log(`Payment processed with giftcard. Generating shipping label.`);
     let trackingNum = generateTrackingNumber();
     resolve([order, trackingNum]);
    } else {
     reject(`Cannot process order: giftcard balance was insufficient.`);
    }  }, generateRandomDelay()); }); };

const shiporder = (responseArray) => {
const order = responseArray[0];
const trackingNum = responseArray[1];
return new Promise ((resolve, reject) => {
setTimeout(() => {
resolve(The order has been shipped. The tracking number is: ${trackingNum}.)M
}, generateRandomDelay());
});
};

function generateTrackingNumber() {
return Math.floor(Math.random() * 1000000);
}

function generateRandomDelay() {
return Math.floor(Math.random() * 2000);
}

module.exports = {checkInventory, processPayment, shipOrder};

Can someone please explain to me what is going on here, i am a little bit confused.

Hi! Where specifically is the part that confuses you?
Is it about promises in general?

Also the code in your post is hard to read, so you might want to format it: How do I format code in my posts?

Yes, Promises in general are a hard concept.

 const checkInventory = (order) => {
  return new Promise((resolve, reject) => {
     setTimeout(() => {
        const itemsArr = order.items;
        let inStock = itemsArr.every(item => store[item[0].inventory >= item[1]);

       if(inStock) {
         let total = 0;
         itemsArr.forEach(item => {
            total += item[1] * store[item[0]].cost
   });
       console.log(`All of the items are in stock. The total cost of the order is ${total}.`);
       resolve([order, total]);
    } else {
       reject(`The order could not be completed because some items are sold out.`);
     }, generateRandomDelay());
      });  };
 const processPayment = (responseArray) => {
   const order = responseArray[0];
   const total = responseArray[1]

   return new Promise ((resolve,reject) => {
      setTimeout( () => {
        let hasEnoughMoney = order.giftcardBalance >= total;

if(hasEnoughMoney) {
     console.log(`Payment processed with giftcard. Generating shipping label.`);
       let trackingNum = generateTrackingNumber();
       resolve([order, trackingNum]);
       } else {
        reject(`Cannot process order: giftcard balance was insufficient.`);
        }  }, generateRandomDelay()); }); };

 const shiporder = (responseArray) => {
     const order = responseArray[0];
      const trackingNum = responseArray[1];
       return new Promise ((resolve, reject) => {
       setTimeout(() => {
        resolve(`The order has been shipped. The tracking number is: ${trackingNum}.`)M
        }, generateRandomDelay());
       });
      };


 function generateTrackingNumber() {
     return Math.floor(Math.random() * 1000000);
 } 

function generateRandomDelay() {
     return Math.floor(Math.random() * 2000); 
} 

Maybe this is more readable.