Created
June 13, 2013 09:06
-
-
Save kaiquewdev/5772310 to your computer and use it in GitHub Desktop.
This file contains 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 itens = [ | |
'apple', | |
'grape', | |
'orange' | |
]; | |
itens | |
.join(',') | |
.replace(/(\w+(?!=\,))/g, '<li>\$1<\li>') | |
.split(','); | |
// [ '<li>apple<\li>', '<li>grape<\li>', '<li>orange</li>' ] |
ˆ ˆ
Outro modo de se fazer :-)
var itens = [
'apple',
'grape',
'orange'
];
function list(word) {
return '<li>' + word + '</li>';
}
itens.map(list);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Teimoso!!!
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach