I'm attempting to substitute all hyphens in attributes with underscores.
<a href="/page" id="someId" data-country="north-america" data-state="north-dakota">North Dakota</a>
This is the code snippet I am using:
var el = document.getElementById('someId');
Array.prototype.slice.call(el.attributes).forEach(function(item) {
item.value.replace('-','_');
console.log(item.value);
});
I can't seem to figure out why the hyphen is not being replaced with an underscore. Is there something crucial that I'm missing?