Practice

Code Challenges

Showing 5 challenges

vending

"1. Start with basic layout: title, selected item, money inserted, message in component return(<> ... </>) \n" + "2. State management for selected item, inserted money and message using useState() \n" + "3. Display all items and coins in the data set in JSX using map() \n" + "4. Event handler for selected item, inserted money, purchase, reset \n" + "5. Attach onClick to button with all event handlers \n\n" + "Notes: inside note.txt",

Try in CodeSandbox

test

"create a two sum function that accepts array and target\n" + " create a map\n" + " loop the array\n" + " create compliment, target - array[i]\n" + " if map has compliment\n" + " return array of map get that compliment and i\n" + " map set that array[i] and i\n" + " return empty array",

Try in CodeSandbox

valid

"create a valid palindrome function that accepts two arrays\n" + " set left to 0\n" + " set right to s2 length - 1\n" + " while left smaller than s1.length AND right bigger than 0\n" + " if s1[left] is not the same as s2[right]\n" + " return false\n" + " left++, right--\n" + " return s1 length ==== s2 length\n",

Try in CodeSandbox

flat

"create an array prototype function with default depth 1\n"

" base case if depth is smaller or equal to 1, return [...this]\n" + " create a empty result array\n" + " loop based on this.length\n" + " if this[i] is array\n" + " result push (...this[i].myFlat(depth - 1))\n" + " else\n" + " result push (this[i])\n" + " return result\n",

Try in CodeSandbox