Hi guys,
I was working on solving my worry, how to visualize x mas tree, for
products displaying in given order.
I could not solve it in one language, I used Ruby and JavaScript, do
you know how to achieve it in only Ruby?
Ruby code:
a = (1..14).to_a.map { |x| x.to_s }
tree = a.map.with_index { |x, i| "<span class='no'></span>" * i }.map
{|x| "<p>#{x}</p>"}
tree[1..-1].each { |x|
puts x
}
JavaScript code:
if($('.no').length > 0) {
$('.no').each(function(index, value) {
this.innerHTML = index+1;
});
}
Thanks, and best wishes during coronavirus madness.
Bartosz Wais
regularlighter.com