By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!i used double equal sign but it showing number is not defined.I told you about global variables and local variables and you make the same mistake over and over.
The = equal sign assigns a value to a variable. The if() needs to look for equality and use the double equal sign ==
And AGAIN, you need to call your functions.
Of course, it's not defined. Global and local variables. Study this page https://www.w3schools.com/js/js_scope.aspi used double equal sign but it showing number is not defined.
And AGAIN, you need to call your functions.
i understood the global and local variables.Of course, it's not defined. Global and local variables. Study this page https://www.w3schools.com/js/js_scope.asp
Go and get an editor!!! I gave you URL for two. Use one! They would not have let you write 'document.getelementbyid("num").innerhtml = 11;' where you forget to capitalize letters. JS IS case sensitive.
is this working ?With everything I have given and shown you so far you should be able to do this on your own. Just stop, take a deep breath, and think about what you want to do. Ask yourself if you want functions and then code it. Give it a try and come back if you're still having problems. But please
<!DOCTYPE html>
<html lang="en">
<head>
<meta
name="viewport"
content="width=device_width, initial_scale=1.0;"
charset="utf_8"
/>
<style></style>
</head>
<body>
<p id="num"></p>
<script>
function function1() {
var number = 1;
function function3() {
if ((number == 1)) {
document.getElementById("num").innerHTML=11;
}
if ((number == 2)) {
document.getElementById("num").innerHTML=22;
}
}
function3();
}
function function2() {
var number = 2;
function function3() {
if ((number == 1)) {
document.getElementById("num").innerHTML=11;
}
if ((number == 2)) {
document.getElementById("num").innerHTML=22;
}
}
function3();
}
function2();
</script>
</body>
</html>
Code Forum is a community platform where coding enthusiasts can connect with other developers, engage in discussions, ask for help, and share their knowledge with a supportive community. It's a perfect place to improve your coding skills and to find a community of like-minded individuals who share your passion for coding.
We use essential cookies to make this site work, and optional cookies to enhance your experience.