How can I execute each switch statement case in JS?

No switch needed:

<a class="profile">...</a>

and

$(".profile").on("click",function(e) { 
  e.preventDefault(); // cancel link
  var idx = $(this).index(); // assuming links in a container   
  $('#contactName').prepend(contacts[idx].name);
  $('#contactPicture').attr('src', contacts[idx].picture);
});

Please note the following:

How do i style a span to look like a link without using javascript?

Leave a Comment