Loading...
More JavaScript Posts
const dragAndDropDiv = editor.container;dragAndDropDiv.addEventListener('dragover', function(e) {e.stopPropagation();e.preventDefault();e.dataTransfer.dropEffect = 'copy';});dragAndDropDiv.addEventListener("drop",function(e){// Prevent default behavior (Prevent file from being opened)e.stopPropagation();e.preventDefault();const files = e.dataTransfer.items; // Array of all filesconsole.assert(files.length >= 1);if (files[0].kind === 'file') {var file = e.dataTransfer.items[0].getAsFile();const fileSize = file.size;const fileName = file.name;const fileMimeType = file.type;reader = new FileReader();reader.onloadend = function(){editor.setValue(reader.result);}reader.readAsText(file);}else{//Maybe handle if text is droppedconsole.log(files[0].kind);}});
var arr = [{"success": true,"data": [{"id": "ipi_1KrrbvDOiB2klwsKhuqUWqt1","object": "issuing.transaction","amount": -2743,"amount_details": {"atm_fee": null},"authorization": "iauth_1KrrbuDOiB2klwsKoFjQZhhd","balance_transaction": "txn_1KrrbwDOiB2klwsK1YkjJJRi","card": "ic_1Krqe5DOiB2klwsK44a35eiE","cardholder": "ich_1KrqL8DOiB2klwsKtBnZhzYr","created": 1650753567,"currency": "usd","dispute": null,"livemode": false,"merchant_amount": -2743,"merchant_currency": "usd","merchant_data": {"category": "advertising_services","category_code": "7311","city": "San Francisco","country": "US","name": "Aeros Marketing, LLC","network_id": "1234567890","postal_code": "94103","state": "CA"},"metadata": {},"type": "capture","wallet": null},{"id": "ipi_1Krrbvc62B2klwsKhuqUWqt1","object": "issuing.transaction","amount": -9999,"amount_details": {"atm_fee": null},"authorization": "iauth_1KrrbuDOiB2klwsKoFjQZhhd","balance_transaction": "txn_1KrrbwDOiB2klwsK1YkjJJRi","card": "ic_1Krqe5DOiB2klwsK44a35eiE","cardholder": "ich_1KrqL8DOiB2klwsKtBnZhzYr","created": 1650753567,"currency": "USD","dispute": null,"livemode": false,"merchant_amount": -9999,"merchant_currency": "usd","merchant_data": {"category": "fast_food","category_code": "7311","city": "San Francisco","country": "US","name": "Aeros Marketing, LLC","network_id": "1234567890","postal_code": "94103","state": "CA"},"metadata": {},"type": "capture","wallet": null}]}];const reduced = arr.reduce((prev, curr) => {prev.push({amount: curr.data[0].merchant_amount,id: curr.data[0].id,currency: curr.data[0].currency,category: curr.data[0].merchant_data.category});console.log(prev)return prev;}, []);
alert("bruh")
import { createSlice } from "@reduxjs/toolkit";const alert = createSlice({name: "alert",initialState: {msg: "",status: "",},reducers: {set_alert: (state, action) => {return {...state,msg: action.payload.msg,status: action.payload.status,};},clear_alert: (state, action) => {return {...state,msg: "",status: "",};},},});export default alert.reducer;const { set_alert, clear_alert } = alert.actions;export const setAlert = (msg, status) => dispatch => {dispatch(set_alert({ msg, status }));setTimeout(() => dispatch(clear_alert()), 4000);};export const clearAlert = () => dispatch => {dispatch(clear_alert());};
const head = arr => (arr && arr.length ? arr[0] : undefined);head([1, 2, 3]); // 1head([]); // undefinedhead(null); // undefinedhead(undefined); // undefined
import React, { useState } from 'react' import Welcome from '../components/Welcome' function About() { const [showWelcome, setShowWelcome] = useState(false) return ( <div> {showWelcome ? <Welcome /> : null} </div> <div> {showWelcome && <Welcome /> } </div> ) } export default App