Skip to content

Instantly share code, notes, and snippets.

Avatar

Ozan Tunca ozantunca

View GitHub Profile
View split-join.js
function removeFromText(text, strToBeRemoved) {
return text.split(strToBeRemoved).join('');
}
removeFromText('lorem+ipsum+dolor+sit+amet', '+');
// -> 'loremipsumdolorsitamet' ✅
View replace-several-examples.js
removeFromText('lorem ipsum dolor sit amet', ' ');
// -> 'loremipsumdolorsitamet' ✅ works
removeFromText('lorem+ipsum+dolor+sit+amet', '+');
// -> throws error ❌
removeFromText('lorem+ipsum+dolor+sit+amet', '+');
// -> still throws error ❌
removeFromText('lorem+ipsum+dolor+sit+amet', '\\+');
View regexp-g.js
function removeFromText(text, strToBeRemoved) {
return text.replace(new RegExp(strToBeRemoved, 'g'), '');
}
View replace-regex.js
'lorem ipsum dolor sit amet'.replace(/ /g, '-');
// -> 'lorem-ipsum-dolor-sit-amet
View replace-single.js
'lorem ipsum dolor sit amet'.replace(' ', '-');
// -> 'lorem-ipsum dolor sit amet'
View replaceall example.js
'lorem ipsum dolor sit amet'.replaceAll(' ', '-');
// -> 'lorem-ipsum-dolor-sit-amet'
View right-type-fn-component.tsx
interface WelcomeProps {
name: string;
}
const Welcome: React.FC<WelcomeProps> = (props) => <h1>Hello, {props.name}</h1>;
View basic-type-fn-component.tsx
interface WelcomeProps {
name: string;
children: React.ReactNode;
}
function Welcome(props: WelcomeProps) {
return <h1>Hello, {props.name}</h1>;
}
View basic-react-fn-comp.js
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
View config.json
{
"widgets": [
{
"name": "WidgetA",
"cdnURL": "....A"
},
{
"name": "WidgetB",
"cdnURL": "....B"
}
You can’t perform that action at this time.