For odd id, I want to show description then image and for even id I want to show image then description. But which code I use is given below.
var rootRef = firebase.database().ref().child("products");
rootRef.on("child_added", snap => {
//alert(snap.val());
var desp = snap.child("description").val();
var image = snap.child("image").val();
var image_and_desp_string =
'<div class="row">'
+ '<div class="col-md-6 col-sm-6 productDetails">'
+ '<p>' + desp + '</p>'
+ '</div>'
+ '<div class="col-md-6 col-sm-6">'
+ '<img src="' + image + '">'
+ '</div>'
+ '</div>';
$("#product_section").append(image_and_desp_string);
});
this code shows image and description side by side for all data. I want to make difference for odd id and even id data. Please help!!
My firebase database is looked like this image.

const id = snap.child('id').val();to get the value. Then check for odd/even:const isEven = id % 2 === 0 ? true : false.