Get ride of commas
I'm doing an english dictionary app, a problem I'm running into is: because of the map function, the code is displaying commas. I want to get ride of the commas, I thought about using "replace" but I'm afraid it will also replace the commas from the examples and definitions texts. Does anyone know how to do this or how to display the content in a better way?
19 Replies
html code
js code
and here is the codepen link
use
.join('')
after the top-most .map
when you return an array from a function, and convert it to a string, you're effectively doing .join(',')
by defaulthere's an example
i see
thxxxxxxxx
you're welcome
you wouldn't suffer this type of issue if you use a
<template>
tag and modify it, then append it to the element you want toHm,Imma look into that
check the mdn website
it has really good examples
Aside from the duplicate ID's and the innerhtml thing. What are the problems with the code?
well, you have unused variables
you re-fetch the template every iteration of the loop
you don't handle cases where
data
is empty
you misspelled items
- please install the codespell extension
you still have a innerHTML
there, which should be changed
your code doesn't hide the parent element before doing changes, which can cause many re-drawsWhich parent element?
meanings
How'd you hide it?
I thought about deleting it from the HTML file, to append it with the other elements
But I'm not sure about this approach
css
Oh
Ic
you can add a class for the current state of that parent's parent
the element above
meanings
can have the "loading" element, and the "meanings" element; then you swap which one is visible based on the class (or a data attribute)I'll use the css later on, I want to work with the js first
good luck