<commit_before>var _ = require('underscore');
var items = require('./items.json');

var total = _.pluck(items, 'price');

//Question 1//
var sum = total.reduce(function(a, b) {
  return (a+b);
});

console.log("The average price is " +  (sum/items.length));

//Question 2 //
<commit_msg>used filter and forEach for 3&4<commit_after>var _ = require('underscore');
var items = require('./items.json');

var total = _.pluck(items, 'price');

//Question 1//
var sum = total.reduce(function(a, b) {
  return (a+b);
});

console.log("The average price is $" +  (sum/items.length).toFixed(2));

//Question 2 //

var filterResult = _.filter(items, function(priceList){
  return Number (priceList.price) > 14 && Number(priceList.price) < 18;
});

filterResult.forEach(function(item){
  console.log(item.title);
}
);


//Question 3//
var filterGBP = _.filter(items,
  function(britishMoney){
    return (britishMoney.currency_code) === "GBP";
  }
  );

filterGBP.forEach(function(item){
  console.log(item.title);
  console.log(" costs £" + (item.price));
}
);

//Question 4 //

var filterWood = _.filter(items,
 function(woody){
   return(woody.materials) === "wood";
 }
 );

filterWood.forEach(function(item){
  console.log(item.title);
}
);

{'fraction_non_alphanumeric': 0.19448946515397084, 'fraction_numerical': 0.01053484602917342, 'mean_word_length': 4.167364016736402, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6447036', 'n_tokens_mistral': 450, 'n_tokens_neox': 430, 'n_words': 90}