Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** Filter by Rating */
  2. const filterRating = function(value) {
  3.   return hotel.filter(function(e) {
  4.     return e.starRating == value;
  5.   });
  6. }
  7.  
  8. /** Filter by Price Range */
  9. const filterPriceRange  = function(min, max) {
  10.   return hotel.filter(function(e) {
  11.     return e[0].totalPrice >= min && e[0].totalPrice <= max;
  12.   });
  13. }
  14.  
  15. /** Filter by Facilities */
  16. const filterFacilities = function(arr) {
  17.   return hotel.filter(function(e) {
  18.     return arr.indexOf(e) > -1;
  19.   });
  20. }
  21.  
  22. /** Actice Filter Rating */
  23. function setRatingFilter() {
  24.   var hotelFilter = JSON.stringify(filterRating(2));
  25.   setItem('hotel_filter', hotelFilter)
  26. }
  27.  
  28. /** Active Filter Price Range */
  29. function setPriceFIlter() {
  30.   var hotelFilter = JSON.stringify(filterPriceRange(2000, 500000));
  31.   setItem('hotel_filter', hotelFilter)
  32. }
  33.  
  34. /** Actice Filter Facilities */
  35. function setFacilitiesFIlter() {
  36.   var facilities = ['wifi', 'bath', 'bbaf'];
  37.   var hotelFilter = JSON.stringify(filterFacilities(facilities));
  38.   setItem('hotel_filter', hotelFilter)
  39. }
  40.  
  41. /** Get Item */
  42. function getItem(item) {
  43.   return localStorage.getItem(item);
  44. }
  45.  
  46. /** Set Item */
  47. function setItem(name, item) {
  48.   return localStorage.setItem(name, item);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement