JavaScript is a dynamically typed imperative programming language with functional features. JavaScript is the main language for programming web pages; however it's use as a general purpose programming language is growing.
JavaScript is generally interpreted.
function doors (n) {
// Create an array with 100 objects
var is_open = [];
// Initialize the array values to false
for (var i = 0; i < n; i++) {
is_open[i] = false;
}
// Process the doors
for (var step = 0; step < n; step += 1) {
for (var idx = step; idx < n; idx += step+1) {
is_open[idx] = !is_open[idx];
}
}
// Print the results
for (i = 0; i < n; i++) {
if (is_open[i]) {
console.log("Door #" + (i+1) + " is open.");
} else {
console.log("Door #" + (i+1) + " is closed.");
}
}
}
doors(100);
JavaScript is the language of the internet. To create an interactive website, JavaScript is the best choice. The web browser is a very capable application development platform and is available for the majority of platforms.
JavaScript has excellent debugging tools and due to the nature of its execution environment, provides a rich set of elements (such as images, audio and text) for displaying results.
JavaScript is a semantically simple language with first-class functions. This makes it very easy to use advanced functional concepts.