<!DOCTYPE html>
<html>
<body>
<p id="displayseries"></p>
<input type = "text" id ="UserInput" />
<button type="button" onClick="MakeSeries()"> Enter number upto which series has to be made.</button>
<script>
function MakeSeries(){
var x = document.getElementById("UserInput").value;
var text = "";
var i;var j = -2;
for (i = 1; i < x; i++) {
text += "+" + i + "
<br>";
i = i+1;
while (j > -x) {
text += j + "
<br>";
j = j-2;
break;
}}
document.getElementById("displayseries").innerHTML = text;
}
</script>
</body>
</html>This code snippet takes user input and then displayes series of alternate positive and negative numbers using javascript.
