• Nov 19, 2022 •CodeCatch
0 likes • 3 views
function Welcome(props) { return <h1>Hello, {props.name}</h1>; } function App() { return ( <div> <Welcome name="Sara" /> <Welcome name="Cahal" /> <Welcome name="Edite" /> </div> ); } ReactDOM.render( <App />, document.getElementById('root') );
const reverse = str => str.split('').reverse().join(''); reverse('hello world'); // Result: 'dlrow olleh'
• Mar 11, 2021 •C S
0 likes • 1 view
const jwt = require("jsonwebtoken"); const authToken = (req, res, next) => { const token = req.headers["x-auth-token"]; try { req.user = jwt.verify(token, process.env.ACCESS_TOKEN_SECRET); next(); } catch (err) { console.log(err.message); res.status(401).json({ msg: "Error authenticating token" }); } }; module.exports = authToken;
//JavaScript program to swap two variables //take input from the users let a = prompt('Enter the first variable: '); let b = prompt('Enter the second variable: '); // XOR operator a = a ^ b b = a ^ b a = a ^ b console.log(`The value of a after swapping: ${a}`); console.log(`The value of b after swapping: ${b}`);
• Oct 15, 2022 •CodeCatch
2 likes • 9 views
var invertTree = function(root) { const reverseNode = node => { if (node == null) { return null } reverseNode(node.left); reverseNode(node.right); let holdLeft = node.left; node.left = node.right; node.right = holdLeft; return node; } return reverseNode(root); };
0 likes • 2 views
import { configureStore } from "@reduxjs/toolkit"; import { combineReducers } from "redux"; import profile from "./profile"; import auth from "./auth"; import alert from "./alert"; const reducer = combineReducers({ profile, auth, alert, }); const store = configureStore({ reducer }); export default store;