I'm quite new to javascript. I'm trying to create a website where you can input when you were born and find out your age in days. My output (variable) is also in JS, so how do I import it and style it in CSS?
Here's the Javascript code:
function ageInDays() {
// variables
var birthYear = prompt("What Year Were You Born In?");
var ageInDayss = (2021 - birthYear) * 365;
var textAnswerYikes = "Yikes... that's old"
// variable CSS
//text
var h1 = document.createElement('h1');
var textAnswer = document.createTextNode("You are " + ageInDayss + " days old. " +
textAnswerYikes)
h1.setAttribute('id', 'ageInDays');
h1.appendChild(textAnswer);
document.getElementById('flex-box-result').appendChild(h1);
}
pelement instead of a text node?document.createElement('p')and then you can style that in CSS. developer.mozilla.org/en-US/docs/Learn/…h1, your element withid="flex-box-result"etc. but styling JS is nonsense.