Imagine I have an array like this:
myarray = ["apple", "apple", "apple", "potato", "apple"];
myarray = ["apple", "apple", "apple", "potato", "apple"];
function listCreate(data) {
var output = '<ul>';
$.each(data, function(key, val) {
output += '<li">';
output += '<h4 >' + val + '</h4>';
output += '</li>';
});
output += '</ul>';
$('#mylist').html(output);
}
listCreate(myarray);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="mylist">
</div>
I generate a list using jQuery
And I need to merge n repeating values and change the li height to n*50px
Example
myarray = ["apple", "apple", "apple", "potato", "apple"];
<ul>
<li style="background:#A6445E; height:150px;">apple</li>
<li style="background:#FFD433; height:50px;">potato</li>
<li style="background:#A6445E; height:50px;">apple</li>
</ul>
Example
myarray =["potato", "volvo", "volvo", "potato", "apple"];
<ul>
<li style="background:#A7777E; height:50px;">potato</li>
<li style="background:#FFD433; height:100px;">volvo</li>
<li style="background:#A4565E; height:50px;">potato</li>
<li style="background:#A2125E; height:50px;">apple</li>
</ul>