This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "my-react-app", | |
"private": true, | |
"version": "0.0.0", | |
"type": "module", | |
"scripts": { | |
"dev": "vite", | |
"build": "vite build", | |
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", | |
"preview": "vite preview", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You have an array. | |
// An item of the array has `name`, a string, and `types`, an array of strings. | |
// The length of `types` in a record can be 1-99 (not always 1-2) | |
// e.g. [{ name: "bulbasaur", types: ["grass", "poison"] }] | |
const pokes = getPokes(); | |
console.log("Pokes", pokes); | |
// Problem 1: Filter by type | |
// - Populate `answer1` with Pokemon names that contain the type string | |
const type = "grass"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findDuplicates(arr1, arr2) { | |
// your code goes here | |
let i = 0 | |
let j = 0 | |
let duplicateArray = [] | |
while (i < arr1.length && j < arr2.length) { | |
if (arr1[i] < arr2[j]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gradingStudents(grades) { | |
grades.forEach((grade,index) => { | |
if (grade >= 38 && grade % 5 >= 3) { | |
grades[index] = grade + 5 - (grade % 5) | |
} | |
}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gradingStudents(grades) { | |
// Write your code here | |
// if grades >= 40 | |
// check if grade - next multiple of 5 is less than 3 | |
// if less than 3 round | |
// else return grade unrounded | |
let results = [] | |
function getNearestMultiple(number, multiple) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pancakeSort(arr) { | |
// code goes here | |
function flip(arr, k) { | |
let arrItem1 = 0; | |
let arrItemK = k; | |
while (arrItem1 < arrItemK){ | |
let temp = arr[arrItem1]; | |
arr[arrItem1] = arr[arrItemK] | |
arr[arrItemK] = temp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {number[]} nums | |
* @param {number} target | |
* @return {number[]} | |
*/ | |
var twoSum = function(nums, target) { | |
const twoSums = [0,0]; | |
for (let i = 0; i < nums.length; i++) { | |
for (let j = i + 1; j < nums.length; j++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lonelyinteger(a) { | |
// Write your code here | |
let len = a.length; | |
if (len == 1) { | |
return 1 | |
} | |
let sorted_arr = a.sort(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function timeConversion(s) { | |
// Write your code here | |
// if hour is 12am, return 00 | |
// if hour is between 1am to 11:59am, return 1 to 11:59 | |
// if time is 12pm, return 12 | |
// if hour is between 1pm to 11:59pm, return 1 + 12 to 11:59 + 12 | |
// Military Hour |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function plusMinus(arr) { | |
// Write your code here | |
let positives = 0; | |
let negatives = 0; | |
let zeros = 0; | |
for (let i = 0; i < arr.length; i++) { | |
if (arr[i] > 0) { | |
positives++ | |
} else if (arr[i] < 0) { |
NewerOlder