Skip to content
Snippets Groups Projects
Commit e0de0dd6 authored by Andrej Rasevic's avatar Andrej Rasevic
Browse files

adding sample code from lecture

parent dc6943d2
No related branches found
No related tags found
No related merge requests found
let team1 = {
teamName: 'The Bullets',
sport: 'Basketball',
city: 'Washington'
}
let team2 = {
teamName: 'The Bullets',
sport: 'basketball',
city: 'Washington'
}
let team3 = team1
function shallowObjectComparison(obj1, obj2) {
let keys1 = Object.keys(obj1)
let keys2 = Object.keys(obj2)
if (keys1.length !== keys2.length) {
return false
}
// there are the same number of keys in each array, i.e. the same number of properties in each object
for (let key of keys1) {
if (obj1[key] !== obj2[key]) {
return false
}
}
return true
}
console.log(team3 === team1)
console.log(team2 === team1)
console.log(shallowObjectComparison(team1, team2))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment