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
| // We import our installed libraries from line 1 to 3 | |
| const Tweet = require('twitter'); | |
| const dotenv = require('dotenv').config(); // Call the config function of dotenv | |
| const readline = require('readline'); | |
| // We create a readline interface for reading and writing user's input: | |
| const rl = readline.createInterface({ | |
| input: process.stdin, | |
| output: process.stdout | |
| }); |
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
| CONSUMER_KEY=REPLACE_WITH_YOURS | |
| CONSUMER_SECRET=REPLACE_WITH_YOURS | |
| ACCESS_TOKEN_KEY=REPLACE_WITH_YOURS | |
| ACCESS_TOKEN_SECRET=REPLACE_WITH_YOURS |
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
| node_modules/ | |
| .env |
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
| // We import our installed libraries from line 1 to 3 | |
| const Tweet = require('twitter'); | |
| const dotenv = require('dotenv').config(); // Call the config function of dotenv | |
| const readline = require('readline'); | |
| /** | |
| * We create a new instance of Tweet which we required | |
| * above passing in our secret information as an object | |
| * and using process.env to fetch the actual value from | |
| * where it was set in our environment variable (.env file) |
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
| // We import our installed libraries from line 1 to 3 | |
| const Tweet = require('twitter'); | |
| const dotenv = require('dotenv').config(); // Call the config function of dotenv | |
| const readline = require('readline'); | |
| /** | |
| * We create a new instance of Tweet which we required | |
| * above passing in our secret information as an object | |
| * and using process.env to fetch the actual value from | |
| * where it was set in our environment variable (.env file) |
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
| // We import our installed libraries from line 1 to 3 | |
| const Tweet = require('twitter'); | |
| const dotenv = require('dotenv').config(); // Call the config function of dotenv | |
| const readline = require('readline'); | |
| /** | |
| * We create a new instance of Tweet which we required | |
| * above passing in our secret information as an object | |
| * and using process.env to fetch the actual value from | |
| * where it was set in our environment variable (.env file) |
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
| var name = 'Fortune'; | |
| var age = 22; | |
| function func() { | |
| // Both name and age can be accessed here | |
| console.log(`The name is ${name}, and I'm ${age} years old`); | |
| } | |
| func() // 'The name is Fortune, and I'm 22 years old' |
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 name = 'Fortune'; | |
| function func() { | |
| let age = 22; | |
| console.log(name, age); | |
| } | |
| func() // 'Fortune 22' | |
| // Accessing age here throws |
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
| for(var i = 1; i <= 5; i++) { | |
| console.log('Number: ' + i); | |
| } | |
| // Variable i is accessible here | |
| console.log(i) // -> 6 - which is the last value of i incremented by 1 | |
| /** | |
| * However, using the ES6 let or const keyword to declare the variable | |
| * makes it behave like a scope as it's only accessible within the for |
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
| console.log(age); // -> undefined | |
| var age = 22; | |
| console.log(age); // -> 22 | |
| console.log(location); // throws -> Uncaught ReferenceError: location is not defined | |
| location = 'Lagos, Nigeria'; | |
OlderNewer