JSFiddle - React, Tailwind, and code Playground

HTML

<p class="phone">2124771000</p>

JavaScript

$(".phone").text(function(i, text) {
        text = text.replace(/(\d\d\d)(\d\d\d)(\d\d\d\d)/, "$1-$2-$3");
        return text;
    });