Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active August 10, 2022 13:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/01d8b33b9bf6091b354cd0b7855eae0c to your computer and use it in GitHub Desktop.
Save McLarenCollege/01d8b33b9bf6091b354cd0b7855eae0c to your computer and use it in GitHub Desktop.
Exercise : User Weather Challenge
let weather = {
    London: {
        temp: 37,
        humidity: 44,
    },
    Patna: {
        temp: 32,
        humidity: 80,
    },
    'New York': {
        temp: 12,
        humidity: 40,
    },
    'New Delhi': {
        temp: 33,
        humidity: 85,
    },
};

let user1 = {
    firstName: 'Paul',
    lastName: 'Jones',
    location: {
        city: 'New York',
        latitude: 40.712,
        longitude: 74.006,
    }
};

let user2 = {
    firstName: 'Mahesh',
    lastName: 'Patil',
    location: {
        city: 'Patna',
        latitude: 25,
        longitude: 40,
    }
};

Task 1

Draw the Object Diagram

Task 2

Create a function called getWeatherDetails that accepts two parameters the user object and the weather object and returns a message in the following format

CODE TEMPLATE


function getWeatherDetails(user, weather){
// write your code here
}
console.log(getWeatherDetails(user1, weather)); // should print 'Hello Paul it is currently 12 degrees Celcius in New York'
console.log(getWeatherDetails(user2, weather)); // should print 'Hello Mahesh it is currently 32 degrees Celcius in Patna'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment