Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

x mas tree, ordering example, https://regularlighter.com/business-opportunity/order

8 views
Skip to first unread message

dzw!

unread,
Apr 19, 2020, 8:06:56 AM4/19/20
to
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
0 new messages