Skip to content

Instantly share code, notes, and snippets.

View katepapineni's full-sized avatar
🚀
Happy to be here!

Kate katepapineni

🚀
Happy to be here!
View GitHub Profile
@katepapineni
katepapineni / typeofQuiz.js
Created July 14, 2020 14:30
JavaScript Quiz 1: Typeof operator
// What is the output?
console.log(typeof NaN);
console.log(typeof Number);
/* Promise.all() => Wait for multiple promises to resolve then proceed */
const promise1 = new Promise((resolve, reject) => {
setTimeout(resolve, 1000, 'Resolving 1');
});
const promise2 = new Promise((resolve, reject) => {
setTimeout(resolve, 2000, 'Resolving 2');
});
const promise3 = new Promise((resolve, reject) => {
setTimeout(resolve, 1000, 'Resolving 3');
});
// What is the output?
const object = {};
console.log(!!Object.keys(object).length);
/* Optional Chaining (?.) in ES2020 */
const app = {
frontend: {
language: 'JavaScript',
framework: 'ReactJS',
},
backend: {
language: 'Python',
},
database: {
const dog1 = {
name: 'Scout',
age: 7,
};
const dog2 = {
name: 'Snoopy',
age: 3,
};
// What's the output?
console.log(NaN == NaN);
console.log(NaN === NaN);
console.log(Number.isNaN(NaN));
const curve = 5;
const students = [
{ name: 'Thor', score: 98 },
{ name: 'Wonder Woman', score: 92 },
{ name: 'Spiderman', score: 98 },
{ name: 'Captain America', score: 88 },
];
const scores = [...new Set(students.map(x => x.score + curve))];
const prices = { beer: 8, water: 1, latte: 4,
soda: 2, coffee: 3, wine: 12, };
function filter(prices) {
return Object.keys(prices).reduce((acc, key) => {
if (prices[key] % 2 === 0) {
delete acc[key];
}
return acc;
}, prices);
const url = 'https://www.myportfolio.com/experience/resume.pdf';
const result = (function(url) {
return url.split('/').pop();
}(url));
// What's the output?
console.log(result);
const first = 200 && 300 && 100;
const second = 0 && 300 && 200;
const third = first || second && 0;
// What's the output?
console.log(first + second + third);