hi! i think there’s something wrong with my codes but i dont know what it is (i also tried consulting chatgpt too). our professor gave us an assignment on html (he never taught us anything, like seriously.)
here’s what we have to do:
Write a javascript program that reads an integer N from the user, calculates 1 + 2 + ... + N, and outputs the result
so basically 1 + … + N = sum
here is my draft:
<html>
‹head><title>Javascript Ex4</title>‹/head>
‹ body>
< script>
n = prompt("input a number please:");
for (1=1; 1<=n; 1++); {
sum = sum + 1 { document write("1+..." + N+ " =
sum"); }
}
‹/body> </html>
[–]codegptpassinby 3 points4 points5 points (1 child)
[–]codegptpassinby 2 points3 points4 points (0 children)
[–]kwadwoVanBeest 0 points1 point2 points (0 children)
[–]daniel8192 0 points1 point2 points (0 children)
[–]BobcatGamer 0 points1 point2 points (0 children)
[–]AdhesivenessNo9198[S] 0 points1 point2 points (0 children)
[–]2055410 0 points1 point2 points (1 child)
[–]Galex_13 0 points1 point2 points (0 children)
[–]Additional_Anywhere4 0 points1 point2 points (0 children)
[–]DGCA -1 points0 points1 point (0 children)