The Code Samurai

Welcome to The Code Samurai ! Your go-to spot for learning to code, from absolute beginner to job-ready. We break down Python, JavaScript, Web Dev, & more with easy-to-follow tutorials and real-world projects. Subscribe for your coding journey!"


The Code Samurai

function foo(x, y, z) {

return x + y + z;

}

const bar = foo.bind(null, 1);

console.log(bar(2, 3));

2 months ago | [YT] | 1

The Code Samurai

What happens here?

const x = () => {};

console.log(x.name);

2 months ago | [YT] | 0

The Code Samurai

What will typeof null return? 🤔

2 months ago | [YT] | 0

The Code Samurai

What will be the output of the following code?

const arr = [1, 2, 3, 4, 5, 6];
const result = arr.filter(num => num % 2 === 0)
.map(num => num * 2)
.reduce((acc, curr) => acc + curr, 0);
console.log(result);

2 months ago | [YT] | 0

The Code Samurai

How do you define a function in JavaScript? 🤔

2 months ago | [YT] | 1

The Code Samurai

What is the right output for the code below?

let count = 0;

const inc = () => ++count;

[inc(), inc(), inc()];

console.log(count);

2 months ago | [YT] | 0

The Code Samurai

What does this code output?


let score = 85;
let grade = score >= 90 ? "A" : score >= 80 ? "B" : "C";
console.log(grade);

2 months ago | [YT] | 1

The Code Samurai

Which statement is used to throw a custom error in JavaScript? 🤔

3 months ago | [YT] | 0

The Code Samurai

What is the output of the following code?


let age = 20;
let status = age >= 18 ? "Adult" : "Minor";
console.log(status);

3 months ago | [YT] | 0

The Code Samurai

When is a switch statement generally preferred over an if-else statement in JavaScript? 🤔

3 months ago | [YT] | 1