This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Encoding | |
| */ | |
| const text = 'This is a sentence.'; | |
| const buf = Buffer.from(text); | |
| console.log({ | |
| text, | |
| base64: buf.toString('base64'), | |
| hex: buf.toString('hex'), | |
| url: encodeURIComponent(text) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://wiki.cdot.senecacollege.ca/w/api.php?action=rsd | |
| http://zenit.senecac.on.ca/~chris.tyler/planet/ | |
| http://www.wordpress.com | |
| http://s9y.org | |
| http://en.wikipedia.org/wiki/RSS_(file_format) | |
| http://en.wikipedia.org/wiki/RSS_(file_format) | |
| http://en.wikipedia.org/wiki/Hackergotchi | |
| http://s-aleinikov.blog.ca/feed/atom/posts/ | |
| http://ejtorre.blog.ca/feed/rss2/posts/ | |
| http://rickeyre.ca/open-source-feed.xml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Function to create a JavaScript library name generator: | |
| // generateName("dog") should return "dog.js" | |
| function generateName(name) { | |
| return name.endsWith('.') ? name + "js" : name + ".js"; | |
| } | |
| let name = "cool" | |
| let library = generateName(name); | |
| console.log(name, library, generateName('cool.')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const linkchecker = (link) => { | |
| //processes Links | |
| let status = 200; | |
| fetch(link.url).then(res => { | |
| const status = res.status; | |
| switch (status) { | |
| case 200: | |
| link.status = StatusEnum.good; | |
| console.log(chalk.green(link.toString())); | |
| break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let s = "The sky above the port was the color of television, tuned to a dead channel"; | |
| function afterComma(value) { | |
| let commaPos = value.indexOf(','); | |
| // No comma found | |
| if(commaPos === -1) { | |
| return value; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let words = ['one', 'two', 'three', 'four', 'five']; | |
| // version 1 - for loop | |
| for(let i = 0; i < words.length; i++) { | |
| let word = words[i]; | |
| console.log(word); | |
| } | |
| // version 2 - for-of loop | |
| for(let word of words) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [email protected] | |
| [email protected] | |
| (\w+)@([\w.]+) | |
| 491 5050 | |
| (416) 491 5050 | |
| (416) 491-5050 | |
| 416-491-5050 | |
| 416 491 5050 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Week 3 - A Larger Example (String, Array, RegExp): | |
| * | |
| * Write a series of functions to accomplish the following, building a larger program as you go: | |
| * | |
| * 1. Split the string into an `Array` of separate rows (i.e., an `Array` with rows separated by `\n`). | |
| * Bonus: how could we deal with data that includes both Unix (`\n`) and Windows (`\r\n`) line endings? | |
| * | |
| * 2. Each row contains information user info: `ID`, `Name`, `Phone Number`, and `Height` info all separated by commas. | |
| * Split each row into an `Array` with all of its different fields. You need to deal with extra and/or no |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Imagine we have a bunch of URLs we need to check (download and check their status code) | |
| const urls = [ | |
| // Most of these are known to be good... | |
| 'https://damontui.blogspot.com/feeds/posts/default?alt=rss', | |
| 'https://dev.to/feed/henryzerocool/', | |
| 'https://danielsirkovich.blogspot.com/feeds/posts/default?alt=rss', | |
| 'https://abdulosd.blogspot.com/feeds/posts/default?alt=rss', | |
| 'http://palak-chawla.blogspot.com/feeds/posts/default?alt=rss', | |
| 'http://zjjiang2.blogspot.com/feeds/posts/default/-/categorylabel?alt=rss', | |
| 'https://dev.to/feed/phast184', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Week 3 - A Larger Example (String, Array, RegExp): | |
| * | |
| * Write a series of functions to accomplish the following, building a larger program as you go: | |
| * | |
| * 1. Split the string into an `Array` of separate rows (i.e., an `Array` with rows separated by `\n`). | |
| * Bonus: how could we deal with data that includes both Unix (`\n`) and Windows (`\r\n`) line endings? | |
| * | |
| * 2. Each row contains information user info: `ID`, `Name`, `Phone Number`, and `Height` info all separated by commas. | |
| * Split each row into an `Array` with all of its different fields. You need to deal with extra and/or no |