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 React, { createContext, useContext, useReducer } from "react"; | |
// Prepares the dataLayer | |
export const StateContext = createContext(); | |
// Wrap our app and provide the Data layer | |
export const StateProvider = ({ reducer, initialState, children }) => ( | |
<StateContext.Provider value={useReducer(reducer, initialState)}> | |
{children} | |
</StateContext.Provider> |
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 bubbleSort(arr) { | |
let temp; | |
let swapped = false | |
for (let i = 0; i < arr.length; i++) { | |
// If the current value is greater than its neighbor to the right | |
if (arr[i] > arr[i + 1]) { | |
// Swap those values | |
temp = arr[i]; | |
arr[i] = arr[i + 1]; |