• Jan 25, 2023 •C S
0 likes • 25 views
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}> <ResponsiveCardImg style={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> ); }
• Sep 13, 2023 •C S
0 likes • 11 views
/** * @param {number[]} nums * @return {number[]} */ var productExceptSelf = function(nums) { var output = []; var leftMult = 1; var rightMult = 1; for (var i=nums.length - 1; i >= 0; i--) { output[i] = rightMult; rightMult *= nums[i]; console.log({output: JSON.stringify(output), i}) } for (var j=0; j < nums.length; j++) { output[j] *= leftMult; leftMult *= nums[j]; console.log({output: JSON.stringify(output), j}) } return output; }; console.log(productExceptSelf([1, 2, 3, 4]))
• Nov 8, 2023 •LeifMessinger
0 likes • 6 views
function copyString(text){ async function navigatorClipboardCopy(text){ if(document.location.protocol != "https:"){ return false; } return new Promise((resolve, reject)=>{ navigator.clipboard.writeText(text).then(()=>{resolve(true);}, ()=>{resolve(false);}); }); } function domCopy(text){ if(!(document.execCommand)){ console.warn("They finally deprecated document.execCommand!"); } const input = document.createElement('textarea'); input.value = text; document.body.appendChild(input); input.select(); const success = document.execCommand('copy'); document.body.removeChild(input); return success; } function promptCopy(){ prompt("Copy failed. Might have ... somewhere. Check console.", text); console.log(text); } function done(){ alert("Copied to clipboard"); } navigatorClipboardCopy(text).catch(()=>{return false;}).then((success)=>{ if(success){ done(); }else{ if(domCopy(text)){ done(); }else{ promptCopy(); } } }); }
• Nov 19, 2022 •CodeCatch
0 likes • 2 views
const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => r.concat(v))), [[]]); powerset([1, 2]); // [[], [1], [2], [1, 2]]
0 likes • 0 views
//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: '); //using destructuring assignment [a, b] = [b, a]; console.log(`The value of a after swapping: ${a}`); console.log(`The value of b after swapping: ${b}`);
• Apr 26, 2025 •hasnaoui1
console.log("xa")