Skip to content

Commit

Permalink
Merge pull request #22 from uclaacm/05-sam
Browse files Browse the repository at this point in the history
05 sam
  • Loading branch information
samuelalsup authored Nov 5, 2020
2 parents c217886 + effca15 commit 16630b4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion 05-more-on-vars-funcs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ addTwoNumbers(num1, num2); // this will result in 8 being printed to the console
One thing we notice here is that our variables themselves are not called number1 and number2! In fact, they can be called anything they want!

In this example, the real variable names were `num1` and `num2`, but JavaScript knows that in our function body when we type `number1` that we just mean the first argument passed to the function.
We now know types of variables in JavaScript and the operations we can do on them, as well as how to write functions in JavaScript with multiple function arguments! We are seriously making progress in having the skills to develop a well-functioning web application!
We now know types of variables in JavaScript and the operations we can do on them, as well as how to write functions in JavaScript with multiple function arguments! We are seriously making progress in having the skills to develop a well-functioning web application!
32 changes: 32 additions & 0 deletions 05-more-on-vars-funcs/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script src="script.js"></script>
<script>
function addTwoNumbers(number1, number2) {
sum = number1 + number2;
console.log(sum);
return sum;
}
function helperFunction() {
num1 = Number(fnum.value);
num2 = Number(snum.value);
result.value = addTwoNumbers(num1, num2);
}
</script>
<h1> Adder </h1>
<label for="fnum">First number:</label>
<input type="number" id="fnum" name="fnum"><br><br>
<label for="snum">Second number:</label>
<input type="number" id="snum" name="snum"><br><br>
<button onclick="helperFunction()">Calculate </button><br><br>
<label for="result">Result:</label>
<input type="number" id="result" name="result">
</body>
</html>

0 comments on commit 16630b4

Please sign in to comment.