Understanding the Digital Revolution Lab - Software
Overview - In this lab, you will write some code in the JavaScript programming language, and explore the free and open-source software community.
Task Details -
Task One - JavaScript
JavaScript is a high-level interpreted programming language. It is built in to every popular web browser, including Chrome, Firefox, Internet Explorer, Edge, and Safari.
This lab assumes you are using Chrome, however most of the functions we'll use have equivalents in other browsers.
To get started, open Chrome and navigate to about:blank Instead of an http or https site. There are a few interesting about: pages which are built in to your browser. Try visiting about:credits
From this (blank) page, press either Ctrl-Shift-J (that is, hold Ctrl and Shift and press J) or F12 to open the Developer Tools for brevity, we'll refer to the Developer Tools as DevTools.
Task 1.a - Using JavaScript as a calculator
See the > character in the Console tab? That is a prompt, a place where you can type JavaScript for it to be executed immediately.
Task 1.b - Talking to the browser
JavaScript by itself can't do much of interest besides cool maths. JavaScript gets much more interesting when you use it to manipulate the web browser itself.
Try typing each of the following lines of code, and again, note the response:
- alert("Hello")
- prompt("How great is this lab?")
- document.write("
Look over here
")
Each of these gave you some way of modifying the page or interacting with the user.
Task 1.c - Variables
When we were exploring machine instructions, we looked at registers and RAM as ways to (temporarily) store values while we were working on them
For instance, in the linear search we stored an memory address at cell 72
JavaScript (and most other programming languages) make this easier for you, by letting you create variables. A variable is analogous to a register or location in RAM, but you don't have to worry about where it is stored in RAM.
Try the following lines of code, in order, to get a sense of what variables are:
- var age = prompt("How old are you?")
- var message = "Your age is " + age;
- alert(message)
Note how we ask the user (you, in this case) for some information, store it in a variable and do something with it. However, we don't need to know or make up an address in RAM in which to store the age.
Task Two - JavaScript using jsFiddle
In Task 1.c you wrote a series of lines of code that combine to make some interesting behaviour. In this exercise, you will write multiple lines of JavaScript to change a web page.
Task 2.a - jsFiddle
Close the DevTools, and in your web browser - jsFiddle is a web site that lets you explore and play with HTML, CSS and JavaScript without needing to run your own web server.
Task 2.b - Functions and Event listeners (Optional, advanced)
Add a
What does the function keyword mean in JavaScript?
What's the closest equivalent you've seen in machine instructions or TIS-100?
Task Three - Free and Open-Source Software
Free software and open-source software have somewhat different meanings, but are often used to describe the same thing - software with permissive licenses, developed in public. GitHub is the most popular (but not the only) site for hosting and managing the development of open- source and free software. It is a collaborative tool that lets programmers and other software developers share and discuss computer code. For this task, create an ePortfolio page to document your investigation.
Attachment:- Assignment Files.rar