• Nov 19, 2022 •CodeCatch
0 likes • 0 views
function Clock(props) { return ( <div> <h1>Hello, world!</h1> <h2>It is {props.date.toLocaleTimeString()}.</h2> </div> ); } function tick() { ReactDOM.render( <Clock date={new Date()} />, document.getElementById('root') ); } setInterval(tick, 1000);
• Nov 18, 2022 •AustinLeath
0 likes • 2 views
//use this with canvas file finder function NewTab(testing) { window.open(testing, "_blank"); } for(test in results) { var testing = 'https://unt.instructure.com/files/' + test + '/download'; NewTab(testing); }
const union = (...arr) => [...new Set(arr.flat())]; // Example union([1, 2], [2, 3], [3]); // [1, 2, 3]
0 likes • 3 views
const euclideanDistance = (a, b) => Math.hypot(...Object.keys(a).map(k => b[k] - a[k])); euclideanDistance([1, 1], [2, 3]); // ~2.2361 euclideanDistance([1, 1, 1], [2, 3, 2]); // ~2.4495
// Get the text that the user has selected const getSelectedText = () => window.getSelection().toString(); getSelectedText();
function formatDate(date) { return date.toLocaleDateString(); } function Comment(props) { return ( <div className="Comment"> <div className="UserInfo"> <img className="Avatar" src={props.author.avatarUrl} alt={props.author.name} /> <div className="UserInfo-name"> {props.author.name} </div> </div> <div className="Comment-text">{props.text}</div> <div className="Comment-date"> {formatDate(props.date)} </div> </div> ); } const comment = { date: new Date(), text: 'I hope you enjoy learning React!', author: { name: 'Hello Kitty', avatarUrl: 'https://placekitten.com/g/64/64', }, }; ReactDOM.render( <Comment date={comment.date} text={comment.text} author={comment.author} />, document.getElementById('root') );