Height and width of the image using JS

I tried to set the height and width of the image using the technique shown here

but the image disappears when I do that.
I had to use the style property too to change the height and width

function change_pic(){
			document.getElementById("coffee").src = "../Coffee-shop project/assets/coffeecards/latte-image.png";
			document.getElementById("coffee").style.height="100px";
			document.getElementById("coffee").style.width="100px";
		}

It isn’t working when I do the following

function change_pic(){
			document.getElementById("coffee").src = "../Coffee-shop project/assets/coffeecards/latte-image.png";
			document.getElementById("coffee").height="100px";
			document.getElementById("coffee").width="100px";
		}

Why is this happening??

Hi @rishav_201900071 ,
Instead of "100px", just punch in 100 and then it should work. 100 here means 100px.