0% found this document useful (0 votes)
9 views8 pages

JavaScript Output Scenarios Explained

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views8 pages

JavaScript Output Scenarios Explained

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

[Link] is output ?

function sum(a, b) {
return a + b;
}
[Link](sum(1, '2'));

[Link] is output ?
let number = 0;
[Link](number++);
[Link](++number);
[Link](number);

3. what is output ?
var num = 8;
var num = 10;
[Link](num);

4. what is output ?
const obj = { a: 'one', b: 'two', a: 'three' };
[Link](obj);

5. what is output ?
function sayHi() {
return (() => 0)();
}
[Link](typeof sayHi());

6. what is output ?
let person = { name: 'Lydia' };
const members = [person];\
person = null;

[Link](members);

7. what is output ?
const person = {
name: 'Lydia',
age: 21,
};

for (const item in person) {


[Link](item);
}

8. what is output ?
[Link](3 + 4 + '5');

9. what is output ?
const num = parseInt('7*6', 10);
clg(num)

10. what is the output ?


function getInfo(member, year) {
[Link] = 'Lydia';
year = '1998';
}

const person = { name: 'Sarah' };


const birthYear = '1997';
getInfo(person, birthYear);

[Link](person, birthYear);

11. what is output ?


[Link](Number(2) === Number(2));
[Link](Boolean(false) === Boolean(false));

12. what is output ?


const list = [1 + 2, 1 * 2, 1 / 2];
[Link](list);

[Link] is output ?
function sayHi(name) {
return `Hi there, ${name}`;
}
[Link](sayHi());

14. what is output ?


const person = {
name: 'Lydia',
age: 21,
};

let city = [Link];


city = 'Amsterdam';

[Link](person);

15. what is output ?


function sum(num1, num2 = num1) {
[Link](num1 + num2);
}
sum(10);

[Link] is output ?
[Link](`${(x => x)('I love')} to program`);

19. what is output ?


const name = 'Lydia Hallie';

[Link](!typeof name === 'object');


[Link](!typeof name === 'string');

[Link] is output ?
const myFunc = ({ x, y, z }) => {
[Link](x, y, z);
};

myFunc(1, 2, 3);

22. let a = 3;
let b = new Number(3);
let c = 3;
[Link](a == b);
[Link](a === b);
[Link](b === c);

23. let greeting;


greetign = {};
[Link](greetig);

24 . function checkAge(data) {
if (data === { age: 18 }) {
[Link]('You are an adult!');
} else if (data == { age: 18 }) {
[Link]('You are still an adult.');
} else {
[Link](`Hmm.. You don't have an age I guess`);
}
}

checkAge({ age: 18 });

25. [Link](typeof typeof 1);

26. const numbers = [1, 2, 3];


numbers[10] = 11;
[Link](numbers);

27 .
let person = { name: 'Lydia' };
const members = [person];
person = null;

[Link](members);

28. const person = {


name: 'Lydia',
age: 21,
};

for (const item in person) {


[Link](item);
}

29. function getInfo(member, year) {


[Link] = 'Lydia';
year = '1998';
}

const person = { name: 'Sarah' };


const birthYear = '1997';

getInfo(person, birthYear);
[Link](person, birthYear);

30. (() => {


let x = (y = 10);
})();

[Link](typeof x);
[Link](typeof y);

31. const name = 'Lydia';


age = 21;

[Link](delete name);
[Link](delete age);

33. function addToList(item, list) {


return [Link](item);
}

const result = addToList('apple', ['banana']);


[Link](result);

34. const box = { x: 10, y: 20 };

[Link](box);

const shape = box;


shape.x = 100;

[Link](shape);

35. const { name: myName } = { name: 'Lydia' };

[Link](name);

36. function checkAge(age) {


if (age < 18) {
const message = "Sorry, you're too young.";
} else {
const message = "Yay! You're old enough!";
}

return message;
}

[Link](checkAge(21));

37. [Link]('I want pizza'[0]);

38. let newList = [1, 2, 3].push(4);


[Link]([Link](5));

39. const person = {


name: 'Lydia',
age: 21,
};

for (const [x, y] of [Link](person)) {


[Link](x, y);
}

40. function nums(a, b) {


if (a > b) [Link]('a is bigger');
else [Link]('b is bigger');
return;
a + b;
}

[Link](nums(4, 2));
[Link](nums(1, 2));

41. const name = 'Lydia';

[Link](name());

42. const one = false || {} || null;


const two = null || false || '';
const three = [] || 0 || true;

[Link](one, two, three);

43. function compareMembers(person1, person2 = person) {


if (person1 !== person2) {
[Link]('Not the same!');
} else {
[Link]('They are the same!');
}
}

const person = { name: 'Lydia' };

compareMembers(person);

44. const colorConfig = {


red: true,
blue: false,
green: true,
black: true,
yellow: false,
};

const colors = ['pink', 'red', 'blue'];

[Link]([Link][1]);

45. let name = 'Lydia';

function getName() {
[Link](name);
let name = 'Sarah';
}

getName();

46. [Link](`${(x => x)('I love')} to program`);

47. const add = x => y => z => {


[Link](x, y, z);
return x + y + z;
};

add(4)(5)(6);

48. const myFunc = ({ x, y, z }) => {


[Link](x, y, z);
};

myFunc(1, 2, 3);

49. const person = { name: 'Lydia Hallie' };

[Link](person);

50 . const person = {
name: 'Lydia Hallie',
address: {
street: '100 Main St',
},
};

[Link](person);

[Link] add = x => x + x;


function myFunc(num = 2, value = add(num)) {
[Link](num, value);
}

myFunc();
myFunc(3);

52. let count = 0;


const nums = [0, 1, 2, 3];

[Link](num => {
if (num) count += 1
})

[Link](count)

53. const user = {


email: "e@[Link]",
password: "12345"
}

const updateUser = ({ email, password }) => {


if (email) {
[Link](user, { email })
}

if (password) {
[Link] = password
}

return user
}

const updatedUser = updateUser({ email: "new@[Link]" })

[Link](updatedUser === user)

54. const user = {


email: "my@[Link]",
updateEmail: email => {
[Link] = email
}
}

[Link]("new@[Link]")
[Link]([Link])

55.
const bird = {
size: 'small',
};
const mouse = {
name: 'Mickey',
small: true,
};

[Link](bird)
[Link](mouse)

You might also like