0

Hi folks I have a quick question. With the help of experts on this forum I was able to get a simple timesheet application going. Everything works great. Im just trying to do one simple adjustment.

Here is the full code: https://jsfiddle.net/tj6bcjos/9/

During this part of the code:

 rw = '<tr><td>'+p.ID+'</td><td>'+p.description+'</td><td>'+
  s.join('<br>')+'</td><td>'+e.join('<br>')+'</td><td>'+h.join('<br>')
  +'</td><td>'+n.join('<br>')+'</td></tr>'

This part in particular: h.join('<br>'). I tried changing it to h.join('<span class="Hours"></span><br>') I was expecting this to return something like <span class='Hours'>(amount of hours)</span><br> but instead getting (amount of hours)<span class='Hours'></span><br>.

I understand now that its not the way the .join function ouputs the data. So I figured I try .join('<span class="Hours">')h.join('</span><br>') but no luck either. Basically I just want every entry in the h array to return <span class='Hours'>(amount of hours)</span><br>. Been scavenging for answers on different forums but seems like I might need to recode this part.

Curios to if you guys have a different approach?

2 Answers 2

2

You can use map:

h.map(function (text) {
  return "<span class='Hours'>" + text + "</span><br>"
})
Sign up to request clarification or add additional context in comments.

Comments

0

and what about that?

'<span class="Hours">' + h.join('</span><br><span class="Hours">') + '</span>'

1 Comment

Wow, dont know how I missed that. That worked as expected. Thank you so much lem :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.