Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How would I make the code below go to \"www.nike.com\" when I swipe right on the

ID: 3724492 • Letter: H

Question

How would I make the code below go to "www.nike.com" when I swipe right on the Nike shoes, "www.converse.com" when I swipe right on the Converse shoes and "www.adidas.com" when I swipe right on the Adidas shoes. When I swipe left I want it to do nothing.

$(document).ready(function () {

// Define cards
var cards =[
new Tindercardsjs.card(2, 'Adidas', 'shoes, $90', 'runners.jpg'),
new Tindercardsjs.card(1, 'Converse', 'shoes, $40.', 'converse.jpg'),
new Tindercardsjs.card(0, 'Nike', 'shoes, $55', 'nike.jpg'),
];

// Render cards

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

if(event.direction === 'right'){  

// swipe right - go next  

window.location.href = 'https://www.nike.com';

}

else{

"";

  

}

Explanation / Answer

Hi... I have added code for the both nike and converse. Please check.

<script>

$(document).ready(function () {

  

// Define cards

var cards =[

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

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

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

];

  

// Render cards

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

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

window.location.href = 'https://www.nike.com';

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

window.location.href = 'https://www.converse.com';

}

  

});

});

</script>

Please check the code and let me know any issues. Thank you. All the best.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote