book

Analysis

After completing the warmup exercises, your task is to do four more slightly more challenges analyses.

How many students like sushi as their favorite food?

var comments = data.comments
var list=_.filter(_.pluck(comments, 'body'), function(text){
	var food=_.last(text.split("Favorite Food:"))
	return _.includes(food, "Sushi")
})

return _.size(list)

The answer is 5.

Who are the students liking Python the most?

var pythonList=_.filter(_.pluck(data.comments, 'body'), function(text){
	return _.includes(text, "Python") || _.includes(text, "python")
})
var names=_.map(pythonList, function(name){
	var a=name.split("\r\n")[0]
	return _.last(a.split("Name:"))
})
return names

Their names are William Farmer, Heather Witte, Zach Lamb, Zhili Yang, John Cronk, Denis Kazakov, Caleb Hsu, Karen Blakemore, Sanketh S Shetty, Andrey Shprengel.

Are there more Javascript lovers or Java lovers?

var jsList=_.filter(_.pluck(data.comments, 'body'), function(text){
	return _.includes(text, "Javascript") || _.includes(text, "javascript")
})
var javaList=_.filter(_.pluck(data.comments, 'body'), function(text){
	return _.includes(text, "Java") || _.includes(text, "java")
})
if(_.size(jsList) > _.size(javaList))
	return "Javascript"
else
	return "Java"

The answer is Java.

Who like the same food as kjblakemore?

var foodList=_.filter(_.pluck(data.comments, 'body'), function(text){
	return _.includes(text, "Vegan")
})
var names=_.map(foodList, function(name){
	var a=name.split("\r\n")[0]
	return _.last(a.split("Name:"))
})
return names

Their names are Karen Blakemore.