let counter = 0;

self.addEventListener(
  "message",
  (e) => {
    counter += 1;
    //console.log(e.data); // First message.
    if (counter == 2) {
      self.postMessage(`${counter} 回目に受け取ったデータ => ${e.data}`);
    }
  },
  false
);

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.