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
import * as React from 'react'; | |
import Listings from './components/presentational/Listings'; | |
export default function App() { | |
return <Listings />; | |
} |
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
import * as React from 'react'; | |
import { StrictMode } from 'react'; | |
import { createRoot } from 'react-dom/client'; | |
import './style.css'; | |
const rootElement = document.getElementById('root'); | |
const root = createRoot(rootElement); | |
const LoadingSpinner = () => ( | |
<div className="spinner-wrapper"> |
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
import * as React from 'react'; | |
import Listings from './components/container/Listings'; | |
export default function App() { | |
return <Listings />; | |
} |
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
import { sum, subtract, divide, multiply } from './math.js'; | |
console.log('Sum', sum(1, 2)); | |
console.log('Subtract', subtract(1, 2)); | |
console.log('Divide', divide(1, 2)); | |
console.log('Multiply', multiply(1, 2)); |
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 counter = 0; | |
// 1. Create an object containing the `getCount`, `increment`, and `decrement` method. | |
const counterObject = { | |
getCount: () => counter, | |
increment: () => ++counter, | |
decrement: () => --counter, | |
}; | |
// 2. Freeze the object using the `Object.freeze` method, to ensure the object is not modifiable. |
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 instance; | |
// 1. Creating the `Counter` class, which contains a `constructor`, `getInstance`, `getCount`, `increment` and `decrement` method. | |
// Within the constructor, we check to make sure the class hasn't already been instantiated. | |
class Counter { | |
constructor() { | |
if (instance) { | |
throw new Error("You can only create one instance!"); | |
} | |
this.counter = counter; |
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
class Dog { | |
constructor(name, age) { | |
this.name = name; | |
this.age = age; | |
} | |
bark() { | |
console.log(`${this.name} is barking!`); | |
} |
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 createUser = (firstName, lastName) => ({ | |
id: crypto.randomUUID(), | |
createdAt: Date.now(), | |
firstName, | |
lastName, | |
fullName: `${firstName} ${lastName}`, | |
}); | |
createUser("John", "Doe"); | |
createUser("Sarah", "Doe"); |
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
import Observer from './observer.js'; | |
export function sendToGoogleAnalytics(data) { | |
console.log('Sent to Google analytics: ', data); | |
} | |
export function sendToCustomAnalytics(data) { | |
console.log('Sent to custom analytics: ', data); | |
} |
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 person = { | |
name: "John Doe", | |
age: 42, | |
email: "john@doe.com", | |
country: "Canada", | |
}; | |
const personProxy = new Proxy(person, { | |
get: (target, prop) => { | |
console.log(`The value of ${prop} is ${target[prop]}`); |
NewerOlder