I'm trying to set the src attribute of the variable avatorhead to the value of the variable avatorheadname but it is returning just the result as text eg either head1, head2, or head3.
I need it to return the value (url) of either head1, head2, or head3.
Any help would be appreciated, Thank you
window.onload = function() {
var avatorhead = new Image();
var avatorheadnum = Math.floor(Math.random() * 3) + 1;
var avatorheadname = 'head' + avatorheadnum;
var head1 = 'https://example.com/pic1.png';
var head2 = 'https://example.com/pic2.png';
var head3 = 'https://example.com/pic3.png';
avatorhead.src = avatorheadname;
};