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 stringPosition(needle, haystack) { | |
var m = needle.length, | |
n = haystack.length; | |
if (!m || !n || m > n) { | |
return -1; | |
} | |
if (m === n) { | |
return needle === haystack ? 0 : -1; |
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 jsonObject = { | |
//key values | |
} | |
const xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
//on complete | |
} | |
} |
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
/* | |
Write a function that reverses a string. The input string is given as an array of characters char[]. | |
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. | |
You may assume all the characters consist of printable ascii characters. | |
*/ | |
const arr = ["h", "e", "l", "l", "o"] |
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
// Cleaner way to manage state and its handlers | |
import React, { useState, useMemo } from 'react'; | |
const Home = (props) => { | |
const [count, { inc, dec }] = useCounter(); | |
return ( | |
<main id="home-component" className="component-container"> | |
<h5>Count {count}</h5> |