Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

05 sam #22

Merged
merged 3 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>