Your javascript isn't going to work because you're declaring, not calling, a function inside your for loop. The function keyword is a declaration, meaning you're creating that function each loop.
Second, you're only ever going to get a single * inside your element because x doesn't change. You're trying to assign it 28 times, but that will just set the value to one asterisk 28 times; Not create a series of asterisks.
Instead, you need to build a single long string using two nested for loops, one for each row, the other for each character (column) in the row. As the outer loop (rows) increases, take it's index and subtract it from the length of the inner loop (columns). This way, as the outer loop increases, the number of times the inner loop iterates decreases. Below is some pseudo code to understand the concept:
for i in 28:
for j in (28 - i):
print '*'
This would result in (variable values wouldn't actually be shown, they're there for clarity):
i = 0 **************************** j = 28 - 0
i = 1 *************************** j = 28 - 1
i = 2 ************************** j = 28 - 2
etc...
To actually display this as separate rows is going to require you also write a <br> tag between each row so that it "breaks" to the next line. Line feeds and other white space characters are not respected in HTML so without the <br> tag, the browser will just render all the rows in a single long line. The pseudo code would be something like:
for i in 28:
for j in (28 - i):
print '*'
print '<br>' # this happens after each loop
This would result in:
****************************<br>
***************************<br>
**************************<br>
etc...
Remember, rather than printing, you'd be appending those * and <br> to a single long string which you can then finally set as innerText or innerHTML on an element.
PS: I've intentionally used pseudo code to help explain the concepts, rather than just give you something to copy-paste.
xto innerHTML 28 times but it's still"*". Try adding it