Giter Club home page Giter Club logo

objects's Introduction

TASK

 let person = { name: "Sarah", country: "Nigeria", job: "Developer" };
let name, country, job;
const { name, country, job } = person;
console.log(name);
for watching task solution click the link

  • Get name, country and jod using destructuring
let person = { name: "Sarah", country: "Armenia", job: "Developer" };
console.log(name); // "Sarah"
console.log(country); // "Nigeria"
console.log(job); // "Developer"
for watching task solution click the link

  • Concatenate the two arrays
const arr1 = [1, 2, 3, 4];
const arr2 = [5, 6, 7, 8, 9];
const arr3; // [1, 2, 3, 4, 5, 6, 7, 8, 9]
for watching task solution click the link

  • How to take arguments in sum function?
function sum() {
return args.reduce((sum, current) => {
return sum + current;
});
}
sum(1, 2); // prints 3
sum(1, 2, 3); // prints 6
for watching task solution click the link

  • How to pass arguments in sum function?
function sum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(sum()); // prints 6
for watching task solution click the link

  • Swapping Values using the Destructuring Assignment
let a = 3;
let b = 6;
console.log(a); //6
console.log(b); //3
for watching task solution click the link

  • Upvotes and downvotes

    • Given an object containing counts of both upvotes and downvotes, return what vote count should be displayed. This is calculated by subtracting the number of downvotes from upvotes.

       getVoteCount({ upvotes: 13, downvotes: 0 }); // ➞ 13
      
for watching task solution click the link

  • 50, 30, 20
    • The 50-30-20 strategy is a simple way to budget, which involves spending 50% of after-tax income on needs, 30% after tax income on wants, and 20% after-tax income on savings or paying off debt.
    • Given the after-tax income as ati, what you are supposed to do is to make a function that will return an object that shows how much a person needs to spend on needs, wants, and savings.
    fiftyThirtyTwenty(10000); // ➞ { "Needs": 5000, "Wants": 3000, "Savings": 2000 }
    fiftyThirtyTwenty(50000); // ➞ { "Needs": 25000, "Wants": 15000, "Savings": 10000 }
    fiftyThirtyTwenty(13450); // ➞ { "Needs": 6725, "Wants": 4035, "Savings": 2690 }
    
for watching task solution click the link

  • Create a one-liner function

    • Create a function that takes an object as an argument and returns a string with facts about the city. The city facts will need to be extracted from the object's three properties:
    name
    population
    continent
    
    • The string should have the following format: X has a population of Y and is situated in Z.(where X is the city name, Y is the population and Z is the continent the city is situated in).
    cityFacts({
    name: "Paris",
    population: "2,140,526",
    continent: "Europe",
    }); // ➞ "Paris has a population of 2,140,526 and is situated in Europe"
    
for watching task solution click the link

  • Create a function that takes infinite count of elements, operator and prints their sum. If there's no operator, then default should be +
printSum("*", 1, 2, 3); // 9
printSum(1, 2, 3, 4, 5); // 15
printSum("-", 1, 2, 3, 6, 7); // -17
printSum("**", 2, 3, 2); // 64
for watching task solution click the link

  • Write object.keys, object.values and object.entries methods using for..in
for watching task solution click the link

  • Lowercase and Uppercase Write a function that creates an object with each (key, value) pair being the (lower case, upper case) versions of a letter, respectively.
mapping(["p", "s"]) ➞ { "p": "P", "s": "S" }
mapping(["a", "b", "c"]) ➞ { "a": "A", "b": "B", "c": "C" }
mapping(["a", "v", "y", "z"]) ➞ { "a": "A", "v": "V", "y": "Y", "z": "Z" }
for watching task solution click the link

objects's People

Contributors

gayane25 avatar

Watchers

 avatar

Forkers

hov001

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.