// Объекты
let student = {
name(n) {
if(n === String) {
return n
} else {
return 'Enter your name in letters'
}
},
years(y) {
if(y === Number) {
return y
} else {
return 'Enter your years in numbers'
}
},
isProgrammer(p) {
if(p === true) {
return
${p} and it's very cool!
} else if(p === false && student.years < 16) {
return
${p} but all still ahead!
} else {
return
${p} OMG, please, don't show me this option!!!
}
},
hobbies(h1, h2, h3) {
if(h1 === String && h2 === String && h3 === String) {
return
${h1}, ${h2}, ${h3}
} else if(h1 !== String) {
return 'Enter your first hobby in letters '
} else if(h2 !== String) {
return 'Enter your second hobby in letters '
} else if(h3 !== String) {
return 'Enter your third hobby in letters '
} else {
return 'Enter your years in letters'
}
}
}
const nameStudent =
student.name('Alex')
const years = student.years(15)
const programmer = student.isProgrammer(false)
const hobbies = student.hobbies('dance', 'pin-pong', 7)
console.log(nameStudent, years, programmer, hobbies)