-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Week3 Yufei Yuan #15
base: master
Are you sure you want to change the base?
Week3 Yufei Yuan #15
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ | |
|
||
<!--javascript imports--> | ||
<script src="leaflet.js"></script> | ||
<script src="part4-data-clean.js"></script> | ||
<script src="part4-data-dirty.js"></script> | ||
<script src="part3-data-clean.js"></script> | ||
<script src="part3-data-dirty.js"></script> | ||
|
||
<script> | ||
|
||
|
@@ -70,9 +70,28 @@ | |
Start code to filter data | ||
|
||
===================== */ | ||
|
||
|
||
|
||
//for clean data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed. It should work now. |
||
var dataFiltered = [] | ||
if (i=1,i<=data.length,i++){ | ||
if (data[i][3]>20){ | ||
dataFiltered.push(data[i]) | ||
} | ||
} | ||
console.log(dataFiltered); | ||
|
||
/* working with dirty data | ||
var data = bikeArrayDirty | ||
var dataFiltered = [] | ||
var DataFilter = (dataArr) => { | ||
for (let i=0; i<data.length; i++){ | ||
if (parseFloat(data[i][3]>20){ | ||
dataFiltered.push(data[i]) | ||
} | ||
} | ||
} | ||
DataFilter(data); | ||
console.log(dataFiltered) | ||
*/ | ||
/* ===================== | ||
|
||
End code to filter data | ||
|
@@ -98,7 +117,8 @@ | |
|
||
===================== */ | ||
|
||
|
||
var makeAMarker = (obj) => {return L.marker([obj[0], obj[1]]).bindPopup(obj[2]+obj[3]).openPopup()} | ||
for (var i=0; i < dataFiltered.length; i++){ makeAMarker(dataFiltered[i]).addTo(map) } | ||
|
||
/* ===================== | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,37 @@ | |
Start code | ||
|
||
===================== */ | ||
|
||
|
||
|
||
//problem 1 | ||
var numArr = [] | ||
for (let i = 1; i<1000; i++){ | ||
if (i%3===0){ | ||
numArr.push(i); | ||
} else if (i%5===0){ | ||
numArr.push(i); | ||
} | ||
} | ||
let numSum=0 | ||
for (let i=0; i<numArr.length; i++){ | ||
numSum=numSum+numArr[i]; | ||
} | ||
console.log(numSum); | ||
|
||
//problem 2 | ||
const arrSum = arr => arr.reduce((a,b) => a + b, 0) | ||
var numArr2 = [1,2]; | ||
let x = 1; | ||
let y = 2; | ||
let evenSum = 2 | ||
while (arrSum(numArr2) < 4000000){ | ||
let z = x + y | ||
if (z%2===0){ | ||
evenSum = evenSum + z; | ||
} | ||
numArr2.push(z); | ||
x = y; | ||
y = z; | ||
} | ||
console.log(evenSum); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are close... But you didn't get the right answer...1089154.. Take a look: https://stackoverflow.com/questions/9053545/finding-the-sum-of-even-valued-terms-in-fibonacci-sequence There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed |
||
/* ===================== | ||
|
||
End code | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,62 +18,54 @@ console.log('Nathan\'s list', nathanGameList); | |
What is the first game in Ross's list? | ||
===================== */ | ||
|
||
var query1; | ||
|
||
var query1 = _.first(rossGameList); | ||
console.log('What is the first game in Ross\'s list?', query1); | ||
|
||
/* ===================== | ||
What are all of the games except for the first game in ross's list? | ||
===================== */ | ||
|
||
var query2; | ||
|
||
var query2 = _.rest(rossGameList); | ||
console.log('What are all of the games except for the first game in Ross\'s list?', query2); | ||
|
||
/* ===================== | ||
What is the last game in Nathan's list? | ||
===================== */ | ||
|
||
var query3; | ||
|
||
var query3 = _.last(nathanGameList); | ||
console.log('What is the last game in Nathan\'s list?', query3); | ||
|
||
/* ===================== | ||
What are all of the games in Nathan's list except for the last? | ||
===================== */ | ||
|
||
var query4; | ||
|
||
var query4 = _.initial(nathanGameList); | ||
console.log('What are all of the games in Nathan\'s list except for the last?', query4); | ||
|
||
/* ===================== | ||
What would Nathan's game list look like if he sold "catan"? | ||
===================== */ | ||
|
||
var query5; | ||
|
||
var query5 = _.without(nathanGameList, "catan"); | ||
console.log('What would Nathan\'s game list look like if he sold "catan"?', query5); | ||
|
||
/* ===================== | ||
If Nathan and Ross play a board game, what are their options? This should be a list of all games owned by ross or Nathan, with no duplicates. | ||
===================== */ | ||
|
||
var query6; | ||
|
||
var query6 = _.union(rossGameList, nathanGameList); | ||
console.log('If Nathan and Ross play a board game, what are their options? This should be a list of all games owned by ross or Nathan, with no duplicates.', query6); | ||
|
||
/* ===================== | ||
Which games are owned by both Ross and Nathan? | ||
===================== */ | ||
|
||
var query7; | ||
|
||
var query7 = _.intersection(rossGameList, nathanGameList); | ||
console.log('Which games are owned by both Ross and Nathan', query7); | ||
|
||
/* ===================== | ||
Which games are exclusive to collections? In other words, only owned by either Ross or Nathan. | ||
===================== */ | ||
|
||
var query8; | ||
|
||
var query8 = _.union(_.difference(rossGameList, nathanGameList), _.difference(rossGameList, nathanGameList)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are taking a union of two things that are the same. Try switching the order of the inputs on one of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed. |
||
console.log('Which games are exclusive to one collection? In other words, only owned by either Ross or Nathan (but not both!).', query8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<=
is giving this error:Try without the
=
it resolves the issue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed. This solved the propblem!