Question

please use proper es6 syntax javscript, use "let" and "const" do not use html, only modern...

please use proper es6 syntax javscript, use "let" and "const"
do not use html, only modern JavaScript

create a function called "write", it should accept an
object and should print to console.

please use destructing in the argument and use empty
default values , examples:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

use template literals syntax when printing to console


printing to the console should be identical to the example below
(the words "Group","captain", and "members" can be hardcoded)

example :

const people1 = {

   ID:'american family'
   captain:'father'
   family: ['son','brother']
}

const people2 = {
   ID :'canadian family'
   family: ['daughter','mother','sister']

}

console.log(write(people1))
console.log(write(people2))

//output should look exactly like this:

Group: american family
captain: father
members: son and brother

Group: canadian family
captain:
members: daughter, mother and sister

0 0
Add a comment Improve this question Transcribed image text
Answer #1

const people1 = {

ID:'american family',

captain:'father',

family: ['son','brother']

}

const people2 = {

ID :'canadian family',

family: ['daughter','mother','sister']

}

function printObjectPeople(people){

const {ID: Group,captain,family : members} = people;

const finaldd = {

Group,

captain,

members

}

if(finaldd.Group)

console.log("Group:",finaldd.Group);

else

console.log("Group:");

if(finaldd.captain)

console.log("captain:",finaldd.captain);

else

console.log("captain:");

if(finaldd.members){

let fam="";

let count =0;

finaldd.members.map(member=>{

if(count>0 && count <finaldd.members.length){

const mem =" and "+member;

fam+=mem;

}else{

fam+= " "+member;

}

count++;

})

console.log("members:",fam);

}


}


printObjectPeople(people1);

output:

Group: american family

captain: father

members: son and brother .

screensot:

output 2:

when people2 given as input

Group: canadian family

captain:

members: daughter and mother and sister

screeshot;

comments:

the above code is executable one with output screenshots plesase save as demo.js js and run node demo.js for the program execution

Add a comment
Know the answer?
Add Answer to:
please use proper es6 syntax javscript, use "let" and "const" do not use html, only modern...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please use proper ES6 JAVASCRIPT SYNTAX including using Let & const correctly Create a function called...

    Please use proper ES6 JAVASCRIPT SYNTAX including using Let & const correctly Create a function called switchLetters that takes a string and an array. *the switchLetters function should accept two arguments , a string and an array. *The function switches letters in the string with a "/" if they are included in the array for example const arr = ['x', 'a', 'h', 'l', 'd' ] replaceLetters('hello', arr) //output: /e//o please do this in javascript es6 syntax

  • please read this articel and write one page summary atleast 250 words: MLB managers learn Spanish...

    please read this articel and write one page summary atleast 250 words: MLB managers learn Spanish to unite teams and clubhouses: At spring training of 1962, the newly hired manager of the San Francisco Giants, Alvin Dark, gathered several of his side's Latin American players together behind second base. Once there, he gave an order that left them surprised, stunned and outraged. "He told us that we couldn't speak Spanish to each other in the clubhouse", said Orlando Cepeda, who...

  • 10. The Beck & Watson article is a Group of answer choices quantitative study qualitative study...

    10. The Beck & Watson article is a Group of answer choices quantitative study qualitative study 11. Beck & Watson examined participants' experiences and perceptions using what type of research design? Group of answer choices particpant obersvation phenomenology 12. Select the participants in the Beck & Watson study Group of answer choices Caucasian women with 2-4 children Caucasian pregnant women 13. In the Beck & Watson study, data was collected via a(n) Group of answer choices internet study focus group...

  • 14. Select the number of participants in the Beck & Watson study Group of answer choices...

    14. Select the number of participants in the Beck & Watson study Group of answer choices 8 13 22 35 15. Beck & Watson determined their final sample size via Group of answer choices coding saturation triangulation ethnography 16.Through their study, Beck & Watson determined Group of answer choices after a traumatic birth, subsequent births have no troubling effects after a traumatic birth, subsequent births brought fear, terror, anxiety, and dread Subsequent Childbirth After a Previous Traumatic Birth Beck, Cheryl...

  • Comprehensive Income Tax Course: Module 1 4. Randy turned 16 last year and had his first...

    Comprehensive Income Tax Course: Module 1 4. Randy turned 16 last year and had his first summer job. Even though his parents are claiming him as a dependent he wants to file a return in order to get his refund. He receives his W-2 and decides he can do his own return using form 1040-EZ. Which of the following information is not found on a Form W-2? a) The taxpayer’s Social Security number b) The taxpayer’s wages, tips and other...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT