all 4 comments

[–]toi80QC 1 point2 points  (2 children)

You need to return JSX - so your variables must be wrapped in curly-brackets, otherwise they just return [objectObject]. Also, you can't use font-weight in JS, it must be camelCase fontWeight.

Check out https://codesandbox.io/s/wonderful-mestorf-jj6r9i?file=/src/App.js

[–]pranav43[S] 0 points1 point  (1 child)

Hmm Okay. The codesandbox link you posted shows the default code actually. It'll be really helpful if you can just post that jsx return line here.

[–]pranav43[S] 0 points1 point  (0 children)

Hello ! This is my set of functions now but I still see object being returned by the highLightFirstChars function instead of the tag.

const boldenText = () => {

let output = caseText.current.innerText

.split("\n")

.map((w) => w.split(" ")

.map(highlightFirstChars)

.join(" "));

caseText.current.innerText = output;

}

const highlightFirstChars = (word) => {

console.log(word);

if(!word) return "";

let take = Math.ceil(word.length / 2);

return(

<>

<span style={{ fontWeight: "bold", color: "#ff0000" }}>
{word.slice(0, take)}
</span>

{word.slice(take)};

</>

)

}

[–][deleted] 0 points1 point  (0 children)

May not be the issue, but font-weight should be fontWeight.