I can show orderB.id as table data. I want to use this value in the href, but I am struggling with syntax.
var output = results.reduce(function (orderA, orderB){
var row = "<tr>";
row += "<td>" + orderB.name + "</td>";
row += "<td>" + orderB.type + "</td>";
row += "<td>" + orderB.id + "</td>";
row += "<td><a href='/update/' + orderB.id + >Update</a></td>";
return orderA + row;
},"")
I have tried:
row += "<td><a href='/update/' + orderB.id + >Update</a></td>";
row += "<td><a href='/update/' + 'orderB.id' + >Update</a></td>";
row += "<td><a href='/update/orderB.id' + >Update</a></td>";
These output:
- /update/
- /update/
- /update/orderB.id
I want for example: /update/3
"and end with"with no break in between. End the literal string, insert the variable, and continue with the rest:"<td><a href='/update/" + orderB.id + "'>Update</a></td>";Your editor should make it pretty clear when you're writing a string and when you're using a variable.