Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code below adds items to an empty array ( stored in localStorage ), when I swipe right on an item. I can see it

The code below adds items to an empty array (stored in localStorage), when I swipe right on an item. I can see it works using "console.log(empty);". My question is how can I print these items on another html page when it loads?

var empty = new Array(100);

localStorage.setItem("cart", JSON.stringify(empty));

var retrievedData = localStorage.getItem("cart");

var cards2 = JSON.parse(retrievedData);

$(document).ready(function () {

var cards =[

new Tindercardsjs.card(2, 'Adidas', 'shoes, $90', 'images/runners.jpg'),

new Tindercardsjs.card(1, 'Converse', 'shoes, $40.', 'images/converse.jpg'),

new Tindercardsjs.card(0, 'Nike', 'shoes, $55', 'images/nike.jpg'),

];

Tindercardsjs.render(cards, $('#main'), function (event) {

if(event.direction === 'right' && event.cardid==0){

empty.push(0, 'Nike', 'shoes, $55', 'images/nike.jpg');

}else if(event.direction === 'right' && event.cardid==1){

empty.push(1, 'Converse', 'shoes, $40.', 'images/converse.jpg');

}

else if(event.direction === 'right' && event.cardid==2){

empty.push(2, 'Adidas', 'shoes, $90', 'images/runners.jpg');

} else{

""; }

//direction 2 = right to left swipe.

//alert('swipe');

});

});

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

Students also viewed these Databases questions

Question

Use a three-step process to develop effective business messages.

Answered: 1 week ago