This program will attempt to show you how to create a global variable that is accessible anywhere within the program and local variable that is only accessible within the method where it is declared. You will need to create script code within the head tags and within the body tags. In the head tags, declare a variable named aNewVariable and assign it the string "is global". Next, create a function call doSomething that accepts the paramenter incompingBits. In the body of your function, create two alert statements. The first should say Global variable within the function: and the variable aNewVariable. The second alert should say Local variable within the function: and the variable incomingBits. In the body tags, call the function doSomething where the argument is a local variable. After calling the function, create two alert statements. The first should say Global var outside the function: and the variable aNewVariable. The second alert statement should say Local var outside the function: and the varible incompingBits. When you run your program, you should see that the first three alert statments work because of the global variable usage, however, the fourth alert statement will not run because incomingBits is a local variable.
This program will attempt to show you how to create a global variable that is accessible anywhere within the program and local variable that is only accessible within the method where it is declared. You will need to create script code within the head tags and within the body tags.
In the head tags, declare a variable named aNewVariable and assign it the string "is global". Next, create a function call doSomething that accepts the paramenter incompingBits. In the body of your function, create two alert statements. The first should say Global variable within the function: and the variable aNewVariable. The second alert should say Local variable within the function: and the variable incomingBits.
In the body tags, call the function doSomething where the argument is a local variable. After calling the function, create two alert statements. The first should say Global var outside the function: and the variable aNewVariable. The second alert statement should say Local var outside the function: and the varible incompingBits.
When you run your program, you should see that the first three alert statments work because of the global variable usage, however, the fourth alert statement will not run because incomingBits is a local variable.
![index.html
<!DOCTYPE html>
<html>
<head>
<title>Working with Functions #1</title>
<script>
4
7
}
8.
</script>
</head>
<body>
<script>
10
11
12
</script>
</body>
</html>|
13
14
15](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F97823ce1-226c-4854-a8f2-c5522ddb99ad%2Ffdd9186c-90a0-41ea-9919-bdfcc37d9c8a%2Fmfhy1eq_processed.png&w=3840&q=75)
![README.md
Preview
1 This program will attempt to show you how to create a global variable that is accessible
anywhere within the program and local variable that is only accessible within the method
where it is declared. You will need to create script code within the head tags and within
the body tags.
3 In the head tags, declare a variable named **aNewVariable** and assign it the string "is
global". Next, create a function call **doSomething** that accepts the paramenter
**incompingBits**. In the body of your function, create two alert statements. The first
should say **Global variable within the function:** and the variable **aNewariable**. The
second alert should say **Local variable within the function:** and the variable
**incomingBits**.
4
In the body tags, call the function **doSomething** where the argument is a local variable.
5
After calling the function, create two alert statements. The first should say **Global var
outside the function:** and the variable **aNewVariable**. The second alert statement
should say **Local var outside the function: ** and the varible **incompingBits**.
when you run your program, you should see that the first three alert statments work because
of the global variable usage, however, the fourth alert statement will not run because
incomingBits is a local variable.
7](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F97823ce1-226c-4854-a8f2-c5522ddb99ad%2Ffdd9186c-90a0-41ea-9919-bdfcc37d9c8a%2F154mdiv_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)