Why the console.log output in quotes?


#1

Objects

Hallo all,

even tough my code is accepted an all ok, I wonder why the quotes are also printed, tried several ways to remove but quite found one…

let person = {
  name: 'Tyron',
  age: 40,
  weekendAlarm: 'No alarms needed',
  weekAlarm: 'Alarm set to 7AM',
  sayHello: () => {
  return 'Hello, there!'
}
};
person.hobbies = ['golf', 'cycling'];
person.hobbies = ['golf'];
console.log(person['name']);
console.log(person['age']);
console.log(person.sayHello());
var day = 'Sunday'
let alarm
if (day === 'Saturday' || day === 'Sunday') {
   alarm = 'weekendAlarm';
} else {alarm = 'weekAlarm'};
console.log(person[alarm]);
console.log(person['hobbies']);

#2

If you print the list, it shows the apostrophes. If you don’t want the apostrophes, you will have to print the items from the array, one way or the other


#3

print from array, which changes I should make ?

others print out normally.


#4

to get elements from array, we could use indexes. Or if you have multiple elements you would like to print, you can use a loop, or a method like .join() which joins array into string


#5

thanks for help, will need to go through previous lessons as stuck here and seems cant solve it…


#6

that is possible, if you include your code and exercise + error message i can also help you, but sometimes its good to rethink everything you did so far.


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.