Skip to content

Instantly share code, notes, and snippets.

View chris-sev's full-sized avatar
🟨
create not consume

Chris Sev chris-sev

🟨
create not consume
View GitHub Profile
@chris-sev
chris-sev / cloudSettings
Last active August 19, 2020 21:35
Visual Studio Code Sync Settings GIST
{"lastUpload":"2020-08-19T21:35:08.705Z","extensionVersion":"v3.4.3"}
@chris-sev
chris-sev / string-replace-example.js
Last active November 27, 2018 01:06
Quick Example
// 1. create a message
const message = 'This is my message.';
// 2. replace message with new thing
// this creates a brand new string. does not change the original variable (message)
const newMessage = message.replace('message', 'new thing');
// 3. output: This is my new thing.
console.log(newMessage);
@chris-sev
chris-sev / replace-http-with-https.js
Last active November 27, 2018 01:10
Replace http with https
// 1. we have a url
const url = "http://scotch.io";
// 2. replace http: with https:
const httpsUrl = url.replace("http:", "https:");
// 3. output: https://scotch.io
console.log(httpsUrl);
@chris-sev
chris-sev / string-replace-all.js
Last active November 27, 2018 08:03
Replace All Instances of a Word
// 1. we have a sentence
const message = 'This is my store. In my store we store store store.'
// 2. replace all store with shop using a regular expression
// normally .replace() will only replace the 1st occurrence
const newMessage = message.replace(new RegExp('store', 'g'), 'shop');
// 3. output: This is my shop. In my shop we shop shop shop.
console.log(newMessage);
@chris-sev
chris-sev / js-string-replace-one.js
Last active December 1, 2018 18:47
Replace One Instance
const myMessage = 'this is the sentence to end all sentences';
const newMessage = myMessage.replace('sentence', 'message');
console.log(newMessage); // this is the message to end all sentences
const myMessage = 'this is the sentence to end all sentences';
const newMessage = myMessage.replace(/sentence/g, 'message');
console.log(newMessage); // this is the message to end all messages
@chris-sev
chris-sev / js-replace-all-regular-expression.js
Created December 1, 2018 18:54
Replace All with RegExp()
const myMessage = 'this is the sentence to end all sentences';
const newMessage = myMessage.replace(new RegExp('sentence', 'g'), 'message');
console.log(newMessage); // this is the message to end all messages
@chris-sev
chris-sev / js-replace-all-special-characters.js
Last active December 1, 2018 19:01
Replace All \- with -
const myUrl = 'this\-is\-my\-url';
// myMessage.replace(/\\-/g, '-');
// or
const newUrl = myUrl.replace(new RegExp('\-', 'g'), '-');
console.log(newUrl); // this-is-my-url
@chris-sev
chris-sev / string-repeat.js
Last active December 5, 2018 00:35
Quick Example
// 1. we have a string
const myString = 'hi there. ';
// 2. repeat over it 5 times
const repeatedString = myString.repeat(5);
// 3. output: hi there. hi there. hi there. hi there. hi there.
console.log(repeatedString);
@chris-sev
chris-sev / string-repeat-emojis.js
Created December 5, 2018 00:33
String repeat() Emojis
"🔥✨🚀".repeat(10);