Skip to content

Commit

Permalink
✨ add more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
w3cj committed Jul 15, 2022
1 parent b391e59 commit cdd94ce
Show file tree
Hide file tree
Showing 8 changed files with 30,955 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
11 changes: 11 additions & 0 deletions basic-web-app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const theBox = document.querySelector('#theBox');

const client = new tmi.Client({
channels: [ 'codinggarden' ]
});

client.connect();

client.on('message', (channel, tags, message, self) => {
theBox.textContent += '\n' + message;
});
17 changes: 17 additions & 0 deletions basic-web-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Awesome Web Page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="theBox" class="my-box">

</div>
<script src="tmi.min.js"></script>
<script src="app.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions basic-web-app/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
* {
box-sizing: border-box;
}

body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: sans-serif;
}

.my-box {
width: 500px;
height: 500px;
background-color: green;
border-radius: 20px;
color: white;
white-space: pre;
word-wrap: break-word;
}
1 change: 1 addition & 0 deletions basic-web-app/tmi.min.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions function-expression-vs-declaration/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
console.log(add(2, 2));

function add(a, b) {
return a + b;
}

const add = function(a, b) {
return a + b;
};

const add = (a, b) => {
return a + b;
};
// export const add = (a, b) => a + b;
30,856 changes: 30,856 additions & 0 deletions json-search/data.json

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions json-search/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const jobPostings = require('./data.json');

// search actual properties...
function getJobPostingsWithRequirementMatch(...matches) {
// Find all jobs that match...
// return jobPostings.filter((jobPosting) => {
// const employmentRequirements = jobPosting.details.find((detail) => {
// return detail.section === 'Employment requirements';
// });
// const matchedDetails = employmentRequirements.details.filter((detail) => {
// return detail.match(new RegExp(match, 'gi'));
// });
// return matchedDetails.length > 0;
// });
return [...jobPostings.reduce((allExamples, jobPosting) => {
// ALTERNATE SOLUTION: stringify each object and regex it
// JSON.stringify(jobPosting).match(someRegexp)
const employmentRequirements = jobPosting.details.find((detail) => {
return detail.section === 'Employment requirements';
});
const allDetails = employmentRequirements.details.join(' ');
const isMatch = matches.every((match) => allDetails.match(new RegExp(match, 'gi')));
if (isMatch) {
const examples = jobPosting.details.find((detail) => {
return detail.section === 'Illustrative example(s)';
});
examples.details.forEach((example) => allExamples.add(example));
}
return allExamples;
}, new Set())];
}

const matchedPostings = getJobPostingsWithRequirementMatch('degree', 'computer science');
console.log(matchedPostings);

0 comments on commit cdd94ce

Please sign in to comment.