'How to combine day with string (text) in HTML with JavaScript

I am trying to combine a day with a string that says "this is the day" in html.

I tried this, it does not concatenate right.

enter image description here



Solution 1:[1]

it's better to use innerText if you don't insert html in your tag

moreover to get the weekday you can avoid stored weekday in an array and directly get it from data object

d.toLocaleString('en-us', {  weekday: 'long' })

const weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; 
const d = new Date(); 
let day = weekday[d.getDay()];
let dayFromdate =  d.toLocaleString('en-us', {  weekday: 'long' });
document.getElementById("demo").innerText = "This is the day, "+ day; 
document.getElementById("demo2").innerText = "This is the day, "+ dayFromdate; 
<div id="demo"></div>
<div id="demo2"></div>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1