Created
January 5, 2017 14:27
-
-
Save RuanAragao/436e224743d148780352e7fbe8ba6ed9 to your computer and use it in GitHub Desktop.
JS Gallery // http://jsbin.com/kamexiq/edit?html,js,output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Gallery</title> | |
</head> | |
<body> | |
<h1>Gallery</h1> | |
<div id="gallery"></div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gallery = document.getElementById('gallery'); | |
var list = [ | |
{ | |
name: "Ruan", | |
car: "Saab", | |
category: "sports" | |
}, | |
{ | |
name: "Carlos", | |
car: "BMW", | |
category: "city" | |
}, | |
{ | |
name: "Aragao", | |
car: "Mercedes", | |
category: "abstract" | |
}, | |
{ | |
name: "Sousa", | |
car: "Volvo", | |
category: "animals" | |
} | |
]; | |
var list_map = list.map(function(data) { | |
return('<img style="margin: 1rem;" src="http://lorempixel.com/220/220/'+data.category+'">'); | |
}); | |
console.log(list_map); | |
gallery.innerHTML = list_map.join(''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment