Solved: Display year copyright

The main problem with displaying the copyright year on digital media is that it can be difficult to determine which years are covered by the copyright. This can be a problem when trying to determine whether or not a particular piece of media is still protected by copyright.

var d = new Date();
var n = d.getFullYear();
document.getElementById("year").innerHTML = n;

This code creates a new date object, then gets the full year from that date object and stores it in the variable n. Finally, it finds the element with id=”year” and changes its innerHTML to the value of n.


In JavaScript, you can use the search() function to search for a string in a text or string buffer. The search() function takes two arguments: the text to search and the string to look for.

The search() function returns an object with two properties: the found text and the position of the found text in the text or string buffer. The found text property contains the matched string, while the position property tells you where in the text or string buffer the matched string was found.

Here’s an example that uses the search() function to find all instances of “cat” in a text file:

var file = “./myfile.txt”; // open the file for reading var contents =“cat”); // get an object containing // foundText and position console.log(contents); // prints “There are no results.”


There are many methods in JavaScript. Some of the most common methods are listed below.

Method Description alert() Displays a message on the screen. bind() Binds a function to a particular event. call() Calls a function. clear() Clears the screen. console.log() Prints information to the console. document.getElementById(id) Retrieves an element by its id attribute. exit() Ends the script execution and returns to the browser’s main window. forEach() Repeats a block of code for each item in an array or collection. if(condition) Evaluates a condition and, if true, executes the code contained within the block; otherwise, it executes another block of code. keydown(event) Triggers an event when a key is pressed down on the keyboard. lastModified Date Returns or sets the date and time at which this document was last modified (in milliseconds). length Returns the length of an object (in bytes). Math.floor(number) Rounds number down to nearest integer value . Math . ceil(number) Rounds number up to nearest integer value . new Date () Creates a new Date object using current date and time as its parameters (in milliseconds). Object clone() Creates and returns a copy of an object obj . prototype Allows you to access properties and methods of an object’s prototype chain (i.e., objects that are derived from this object). pushStackTrace(stackTrace) Adds stack trace information to an error message being displayed by console . setTimeout(time, [callback]) Sets a timeout for execution of code after given amount of milliseconds elapses; if callback is provided, it will be executed after timeout expires setInterval(time, [callback]) Sets an interval for execution of code after given amount of milliseconds elapses; if callback is provided, it will be executed every time interval expires

Related posts:

Leave a Comment