# Get Help with Java Script Code: Calculate Day Count Since 1922 Dec. 18

• Java
• Helios
In summary: Replace it with:var elm = document.createElement("div");elm.innerHTML = bln(difference);document.body.appendChild(elm);
Helios
Dear Computer People,
I know nothing about Java. What I understand what "Java script" means is something that one can paste into an html document or web page. What I have is a Java script code that displays a day count since 1922 December 18. Here it is.

<script>
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
function countup(yr,m,d){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy
var paststring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1)
difference+=" Days"
document.write("The Day Count is "+difference+" at present.")
}
//enter the count up date using the format year/month/day
countup(1922,12,18)
</script>

As you can see (1922, 12, 18) is in the last line of code.
Now I would think that this day count D could be used in the function,

BLN = D*( 1749 / 51649 ) - 781 / 51649

where BLN is the "Brown Lunation Number",
and the altered code could yield an output that would appear as ( for example )

Today's Brown Lunation Number is 1075 & 48302 / 51649

If anyone can offer this Java script code, I am grateful.

Not sure if I got the math right, but:

function bln(d) {
var n = d * ( 1749 / 51649 ) - 781 / 51649;
var frac = (n - parseInt(n,10));
var denom = 51649;
var numer = frac * denom;

return "Today's Brown Lunation Number is " + parseInt(n,10) + " & " + parseInt(numer,10) + " / " + denom;
}

P.S. Java and javascript are completely different languages

Last edited:
Dear David,
This is the page I put the code on.

http://www.helios.netne.net/brown.htm

Unfortunately, it doesn't show the output.

Replace
document.write("The Day Count is "+difference+" at present.")
with
document.write(bln(difference))

Dear David,
The output is now
Today's Brown Lunation Number is NaN & NaN / 51649

http://www.helios.netne.net/brown.htm

try taking out difference+=" Days"

Oh! I think it works. Thanks so much.

Helios said:
Oh! I think it works. Thanks so much.

Also, I would suggest that in your javascript replace document.write(bln(difference)) with:

var elm = document.createElement("div");
elm.innerHTML = bln(difference);
document.body.appendChild(elm);

Document.write causes problems.

## 1. What is Java Script code?

Java Script code is a programming language commonly used for creating interactive and dynamic elements on websites. It is often used in conjunction with HTML and CSS to add functionality to web pages.

## 2. How do I write Java Script code?

To write Java Script code, you need to have a basic understanding of the language's syntax and structure. You can write Java Script code in a text editor and save it with a .js extension. This code can then be linked to an HTML file or embedded directly into an HTML document using < script > tags.

## 3. What are some common uses for Java Script code?

Java Script code is commonly used for creating interactive elements such as dropdown menus, forms, and image sliders on websites. It is also used for validating user input and creating animations.

## 4. Are there any resources available for learning Java Script code?

Yes, there are many online resources available for learning Java Script code, such as tutorials, courses, and coding challenges. Some popular websites include Codeacademy, W3Schools, and FreeCodeCamp.

## 5. Can I use Java Script code in all web browsers?

Yes, Java Script code is supported by all modern web browsers, including Chrome, Firefox, Safari, and Internet Explorer. However, older browsers may not support all of the latest Java Script features, so it is important to test your code in different browsers.