You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

116 lines
3.3 KiB

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Learning Website</title>
<link href="/styles/styles.css" rel="stylesheet" type="text/css">
<link href="/webdevelopment/styles/styles.css" rel="stylesheet" type="text/css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="banner">
<h1 class="courselink">JavaScript Essential Training</h1>
<h2 class="lecturer">LinkedIn Learning : Morten Rand-Hendriksen</h2>
<h2 class="episodetitle">Build a Function - JavaScript</h2>
</div>
<article>
<h2 class="sectiontitle">This is the JavaScript code I created for the practice in the chapter on Functions under Practice: Build a Function.</h2>
<pre class="codesample">
/**
* Practice: Pass values between functions
*/
const main = document.querySelector("main");
const webServer = {
name: "Raspberry Pi 4",
ip: "192.168.0.20",
mac: "dc:a6:32:d9:4d:37",
};
function addServer(server) {
const newArticle = document.createElement("article");
newArticle.innerHTML =`
&lt;h1&gt;${server.name}&lt;/h1&gt;
&lt;h2&gt;Addresses&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;IP Address: ${server.ip}&lt;/li&gt;
&lt;li&gt;MAC Address: ${server.mac}&lt;/li&gt;
&lt;/ul&gt;
;`
return newArticle;
};
const blueTitle = function() {
const anElement = document.querySelector("h1");
anElement.style.color="blue";
};
main.append(addServer(webServer));
blueTitle();
(function() {
const server = {
name: "Dev Machine",
ip: "192.168.0.15",
mac: "00:13:ef:f2:16:a3",
};
const newArticle = document.createElement("article");
newArticle.innerHTML =`
&lt;h1&gt;${server.name}&lt;/h1&gt;
&lt;h2&gt;Addresses&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;IP Address: ${server.ip}&lt;/li&gt;
&lt;li&gt;MAC Address: ${server.mac}&lt;/li&gt;
&lt;/ul&gt;
;`
main.append(newArticle);
})();
(() =&gt; {
const server = {
name: "Work Machine",
ip: "192.168.0.10",
mac: "f0:79:59:8c:cb:d9",
};
const newArticle = document.createElement("article");
newArticle.innerHTML =`
&lt;h1&gt;${server.name}&lt;/h1&gt;
&lt;h2&gt;Addresses&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;IP Address: ${server.ip}&lt;/li&gt;
&lt;li&gt;MAC Address: ${server.mac}&lt;/li&gt;
&lt;/ul&gt;
;`
main.append(newArticle);
})();</pre>
</article>
<div class="btngroup">
<button class="button" onclick="window.location.href='../../../functions.html#baf_return';">
Back to Functions Chapter
</button>
<button class="button" onclick="window.location.href='javascriptessentialtraining2021.html'">
Course Contents
</button>
<button class="button" onclick="window.location.href='/webdevelopment/webdevelopment.html'">
Web Development Page
</button>
<button class="button" onclick="window.location.href='/index.html'">
Home
</button>
</div>
</body>
</html>