Loading...
More JavaScript Posts
const quickSort = arr => {const a = [...arr];if (a.length < 2) return a;const pivotIndex = Math.floor(arr.length / 2);const pivot = a[pivotIndex];const [lo, hi] = a.reduce((acc, val, i) => {if (val < pivot || (val === pivot && i != pivotIndex)) {acc[0].push(val);} else if (val > pivot) {acc[1].push(val);}return acc;},[[], []]);return [...quickSort(lo), pivot, ...quickSort(hi)];};quickSort([1, 6, 1, 5, 3, 2, 1, 4]); // [1, 1, 1, 2, 3, 4, 5, 6]
const celsiusToFahrenheit = (celsius) => celsius * 9/5 + 32;const fahrenheitToCelsius = (fahrenheit) => (fahrenheit - 32) * 5/9;// ExamplescelsiusToFahrenheit(15); // 59celsiusToFahrenheit(0); // 32celsiusToFahrenheit(-20); // -4fahrenheitToCelsius(59); // 15fahrenheitToCelsius(32); // 0
import Head from 'next/head'import Image from 'next/image'import styles from '../styles/Home.module.css'const { exec } = require("child_process");exec("sensors|grep "high"|grep "Core"|cut -d "+" -f2|cut -d "." -f1|sort -nr|sed -n 1p", (error, stdout, stderr) => {if (error) {console.log(`error: ${error.message}`);return;}if (stderr) {console.log(`stderr: ${stderr}`);return;}console.log(`stdout: ${stdout}`);});export default function Home() {return (<div className={styles.container}><Head><title>Create Next App</title><meta name="description" content="Generated by create next app" /><link rel="icon" href="/favicon.ico" /></Head><main className={styles.main}><h1 className={styles.title}>Welcome to <a href="https://nextjs.org">Next.js!</a></h1><p className={styles.description}>Get started by editing{' '}<code className={styles.code}>pages/index.js</code></p><div className={styles.grid}><a href="https://nextjs.org/docs" className={styles.card}><h2>Documentation →</h2><p>Find in-depth information about Next.js features and API.</p></a><a href="https://nextjs.org/learn" className={styles.card}><h2>Learn →</h2><p>Learn about Next.js in an interactive course with quizzes!</p></a><ahref="https://github.com/vercel/next.js/tree/canary/examples"className={styles.card}><h2>Examples →</h2><p>Discover and deploy boilerplate example Next.js projects.</p></a><ahref="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"className={styles.card}><h2>Deploy →</h2><p>Instantly deploy your Next.js site to a public URL with Vercel.</p></a></div></main><footer className={styles.footer}><ahref="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"target="_blank"rel="noopener noreferrer">Powered by{' '}<span className={styles.logo}><Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} /></span></a></footer></div>)}
results ={"11345240":"Media Comment-80e47004-1719-493a-af69-a43b2652b41c","11345282":"zoom_3_22_21.mp4","11345303":"Recording-2.m4a","11345348":"February 12%2C 2021.mp4","11345826":"Lecture_Rousso_Chapter_06-2.pptx","11345933":"Themes_InClassAssigment.pptx","11346193":"Agenda – Week of March23.pptx","11346318":"MUJS 2370 SP2021 Updated Rhythm Changes Drills Bb - Score.pdf","11346319":"MUJS 2370 SP2021 Updated Rhythm Changes Drills C - Score.pdf","11346322":"MUJS 2370 SP2021 Updated Rhythm Changes Drills Eb - Score.pdf","11346323":"MUJS 2370 Updated Rhythm Changes Drills Bass - Score.pdf","11346381":"Anthropology with colored highlighter analysis - Mar 22 2021 - 10-36 AM.pdf","11346449":"Anthropology with colored highlighter analysis - Mar 22 2021 - 10-36 AM.pdf","11346450":"MUJS 2370 SP2021 Updated Rhythm Changes Drills Bb - Score.pdf","11346451":"MUJS 2370 SP2021 Updated Rhythm Changes Drills C - Score.pdf","11346453":"MUJS 2370 SP2021 Updated Rhythm Changes Drills Eb - Score.pdf","11346454":"MUJS 2370 Updated Rhythm Changes Drills Bass - Score.pdf","11346495":"Steinel chromatic ornamentation étude rhythm changes - Aug 23 2020 - 12-19 PM.pdf","11346532":"Media Comment-136242b4-7f2c-4d5d-8aa4-091f07e797cf","11346581":"2019 Trust Based Relationship Intervention Manual.pdf","11346584":"TBRI ppt.pptx","11346593":"Trauma informed care.ppt"}function NewTab(testing) {window.open(testing, "_blank");}for(test in results) {var testing = 'https://unt.instructure.com/files/' + test + '/download';NewTab(testing);//window.open = 'https://unt.instructure.com/files/' + test + '/download';}
// There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9.// You are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring where:// The first character of the ith pair denotes the ith ring's color ('R', 'G', 'B').// The second character of the ith pair denotes the rod that the ith ring is placed on ('0' to '9').// For example, "R3G2B1" describes n == 3 rings: a red ring placed onto the rod labeled 3, a green ring placed onto the rod labeled 2, and a blue ring placed onto the rod labeled 1.// Return the number of rods that have all three colors of rings on them.let rings = "B0B6G0R6R0R6G9";var countPoints = function(rings) {let sum = 0;// Always 10 Rodsfor (let i = 0; i < 10; i++) {if (rings.includes(`B${i}`) && rings.includes(`G${i}`) && rings.includes(`R${i}`)) {sum+=1;}}return sum;};console.log(countPoints(rings));
const linearSearch = (arr, item) => {for (const i in arr) {if (arr[i] === item) return +i;}return -1;};linearSearch([2, 9, 9], 9); // 1linearSearch([2, 9, 9], 7); // -1