Machine Coding questions in Vanilla Javascript