How to make a part of a string bold?

the tasks below shall be completed using Web Document API functions and using neither the innerHTML nor the innerText property.

I want to bold just the violation part of the string in str3.

The only things I can find are using innerHTML which isn’t allowed.

Here is my JavaScript code:

// Find the placeholder node in the HTML document
const div0 = document.getElementById("part0");

// Create a new H2 and its text
const h0: HTMLHeadingElement = document.createElement("h2");
const h0text: Text = document.createTextNode("Part 0");

// Create a paragraph as its text
const par0: HTMLParagraphElement = document.createElement("p");
var str1 = ("Random");
var str2 = (" Random");
var str3 = ("someone else is a violation of academic honesty.");
var bold1 = ["violation"];

const par0text: Text = document.createTextNode(str1 
    + str2 
    + str3);

and here is my HTML code:

    <script src="./part0.ts" defer>
    <link rel="stylesheet" href="" />
    <link rel="stylesheet" href="mystyle.css" />
    <div id="mocha"></div>
    <div id="part0" class="result"></div>
    <script src=""></script>
    <script src=""></script>
    <script src=""></script>
    <script class="mocha-init">
    <script src="./mocha-checker.ts"></script>
    <script class="mocha-exec">;

30 thoughts on “How to make a part of a string bold?”

  1. 223484 704148This really is such an excellent resource that you are offering and you give out at no cost. I appreciate seeing sites that realize the worth of offering a perfect helpful resource entirely free. I genuinely loved reading your submit. 197576

  2. What i do not realize is in truth how you
    are now not really a lot more well-appreciated than you
    may be right now. You’re very intelligent. You understand thus considerably in the case of this subject, produced me for my part believe it from a lot of numerous angles.
    Its like women and men aren’t involved except it is something to accomplish with Girl gaga!
    Your individual stuffs great. All the time care for it up!

  3. I just couldn’t go away your web site prior to suggesting
    that I really loved the standard info a person provide in your guests?
    Is gonna be back ceaselessly in order to check out new posts

  4. I think this is one of the most vital info for me.

    And i’m glad reading your article. But want to remark on few general things, The web site style is great,
    the articles is really nice : D. Good job, cheers


Leave a Comment