Using a for loop with Chrome Notifications results in wrong onclick link
<p>I have been writing a Javascript file that calls a for loop and on each iteration of the loop programmatically creates a new link that gets pushed to the user via browser push notification. These unique links are also appended to the notifications as onclick events. I run the code and try to click on the notifications, however I found that rather than each notification having it's own unique onclick link, all consecutive notifications have taken on the onclick of the most recent notification. </p>

<p>I have included a barebones code here that demonstrates the issue I'm facing: <a href="https://jsbin.com/loyeviguqu/1/edit?html,js,output" rel="nofollow">https://jsbin.com/loyeviguqu/1/edit?html,js,output</a></p>

<p>*edit: sorry I quickly realized I had linked to the wrong jsbin, the correct link is now updated</p>

<p>From the code I have written, you will see that I create 3 links google.com/0, google.com/1, google.com/2 with a for loop. Furthermore in the for loop for each iteration I append the link as a onclick event to the notification. However you will see clicking on any of the 3 notifications will always result in the google.com/2, rather than any of the other two. The text in the notifications however retain their uniqueness. </p>

<p>My current suspicion is the each time I append an onclick to the notification it overwrites the old one, however I'm at a loss at how to fix this. </p>

<p>Any explanation or insight into the issue would be greatly appreciated! Thanks! </p>