Loading...
More JavaScript Posts
const reverse = str => str.split('').reverse().join('');reverse('hello world');// Result: 'dlrow olleh'
const insertionSort = arr =>arr.reduce((acc, x) => {if (!acc.length) return [x];acc.some((y, j) => {if (x <= y) {acc.splice(j, 0, x);return true;}if (x > y && j === acc.length - 1) {acc.splice(j + 1, 0, x);return true;}return false;});return acc;}, []);insertionSort([6, 3, 4, 1]); // [1, 3, 4, 6]
let nums = [1,2,3,1]var containsDuplicate = function(nums) {let obj = {};for(let i =0; i< nums.length; i++){if(obj[nums[i]]){obj[nums[i]] += 1;return true;}else{obj[nums[i]] = 1;}}return false;};console.log(containsDuplicate(nums));
const ResponsiveCardImg = styled(Card.Img)`// For screens wider than 768px@media(min-width: 768px) {// Your responsive styles here.}// For screens smaller than 768px@media(max-width: 768px) {// Your responsive styles here.}`export default function App() {return (<MainContainer><Container><Card text='white' bg='dark' style={styles.mainCard}><ResponsiveCardImgstyle={styles.cardImage}onClick={handleClick}src={apeImage}alt='Degenerate Ape Academy'/><Card.Body><Card.Title className='text-center' as='h2'>{apeId}</Card.Title></Card.Body></Card></Container></MainContainer>);}
if (process.env.NODE_ENV === "production") {app.use(express.static("client/build"));app.get("*", (req, res) => {res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));});}
// `arr` is an arrayconst clone = arr => arr.slice(0);// Orconst clone = arr => [...arr];// Orconst clone = arr => Array.from(arr);// Orconst clone = arr => arr.map(x => x);// Orconst clone = arr => JSON.parse(JSON.stringify(arr));// Orconst clone = arr => arr.concat([]);