destructuring exercise

can't make add space before every skill/language in their array
pull/98/head
nam dang tran 5 years ago
parent a980fb9187
commit 256bc7f17f

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Destructuring</title>
</head>
<body>
</body>
</html>
<script>
const person = {
firstName: 'Asabeneh',
lastName: 'Yetayeh',
age: 250,
country: 'Finland',
job: 'Instructor and Developer',
skills: [
'HTML',
'CSS',
'JavaScript',
'React',
'Redux',
'Node',
'MongoDB',
'Python',
'D3.js',
],
languages: ['Amharic', 'English', 'Suomi(Finnish)'],
}
const getPersonInfo = ({ firstName, lastName, age, country, job, skills, languages }) => {
const lastSkill = skills.splice(skills.length - 1, 1);
const lastLang = languages.splice(languages.length - 1, 1);
return `${firstName} lives in ${country}. He is ${age} years old. He is an ${job}. He teaches ${skills} and ${lastSkill}. He speaks ${languages} and a little bit of ${lastLang}.`
};
console.log(getPersonInfo(person));
/*
Asabeneh Yetayeh lives in Finland. He is 250 years old. He is an Instructor and Developer. He teaches HTML, CSS, JavaScript, React, Redux, Node, MongoDB, Python and D3.js. He speaks Amharic, English and a little bit of Suomi(Finnish)
*/
</script>
Loading…
Cancel
Save