My JavaScript is adding inputs as strings. How can I turn them into integers to give me a correct total amount?

<!DOCTYPE html>
	<title>This is a test</title>
<form id="form1">
	Size: <input type="number" name="sizes" size="10"><br>
	Bow: Yes<input type="radio" name="bow" value=5 />
				No <input type="radio" name="bow" value=0 /><br>
	Stern: Yes<input type="radio" name="stern" value=5 />
				No<input type="radio" name="stern" value=0 />
<button onclick="outputsize()">Submit</button>
function outputsize() {
	var x,y,b,s,sizes;

	x=document.getElementById("form1") ;
	document.getElementById("demo").innerHTML=(y * 2+b+s);



<h1 id="demo"></h1>

maybe use something like parseInt ?

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


Thank you. I was wondering how to make the post viewable.

You could also use the Number function to convert strings to numbers. You need to convert the input values because they are strings.

	y= Number(x.elements["sizes"].value);
	b= Number(x.elements["bow"].value);
	s= Number(x.elements["stern"].value);

The Number Function did the trick. I was at a lost, but that makes complete sense.. Thank you so much for the helpful advice.

Thank you for your suggestion. Using the Number Function was able to get me the result I was looking for.