• 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); }
• Nov 19, 2022 •CodeCatch
const arithmeticProgression = (n, lim) => Array.from({ length: Math.ceil(lim / n) }, (_, i) => (i + 1) * n ); arithmeticProgression(5, 25); // [5, 10, 15, 20, 25]
0 likes • 0 views
const primes = num => { let arr = Array.from({ length: num - 1 }).map((x, i) => i + 2), sqroot = Math.floor(Math.sqrt(num)), numsTillSqroot = Array.from({ length: sqroot - 1 }).map((x, i) => i + 2); numsTillSqroot.forEach(x => (arr = arr.filter(y => y % x !== 0 || y === x))); return arr; }; primes(10); // [2, 3, 5, 7]
• Aug 13, 2023 •CAS
1 like • 2 views
function sortNumbers(arr) { return arr.slice().sort((a, b) => a - b); } const unsortedArray = [4, 1, 9, 6, 3, 5]; const sortedArray = sortNumbers(unsortedArray); console.log("Unsorted Numbers:", unsortedArray); console.log("\n"); console.log("Sorted Numbers:", sortedArray);
• Jan 26, 2023 •AustinLeath
0 likes • 5 views
function printHeap(heap, index, level) { if (index >= heap.length) { return; } console.log(" ".repeat(level) + heap[index]); printHeap(heap, 2 * index + 1, level + 1); printHeap(heap, 2 * index + 2, level + 1); } //You can call this function by passing in the heap array and the index of the root node, which is typically 0, and level = 0. let heap = [3, 8, 7, 15, 17, 30, 35, 2, 4, 5, 9]; printHeap(heap,0,0)
• Mar 11, 2021 •C S
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;