Display a portion of text from a certain div in the TITLE?

You should print the first 50 characters of a certain div in the title of the website, how can I do that?

Say there is a div with the class f_content where there is text, I need the first 50 simoom inserted in title
June 3rd 19 at 20:58
1 answer
June 3rd 19 at 21:00
<div id="f_content">
 This is a very large text and did not need anyone to write to the page header
</div>
the <script>
 const d = document.getElementById("f_content");
 document.title = d.innerHTML.substring(0,50);
 </script>

Find more questions by tags JavaScriptHTMLjQuery