JavaScript Loop Samples

Print numbers from 1 to 10 on the screen. for (i = 1; i <= 10; i++) { document.write(i+"<br>") } print 10 times in the bottom. for (i = 1; i <= 10; i++) { document.write("I love codeblogger"+"<br>") } List the ones with numbers from 1-50 on the screen. for (i = 1; i <=... Continue Reading →

Finding Angles in a Triangle with JavaScript

CODE: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>page</title> <style> body { padding: 0; margin: 0; font-family: Arial; background: #262626; } .container { width: 500px; height: 180px; background-color: #d7d7d7; border-radius: 10px; padding: 20px; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); } input[type="text"] { width: 460px; padding: 4px; margin:8px; } input[type="button"] { cursor: pointer; padding:... Continue Reading →

Arrow Functions (JavaScript)

With this method, we can define anonymous function expressions in a short way. Example: var collection = (x, y) => x + y; document.write(collection(3,7)) Output:  10 Same as above example: var collection = function (x, y) { return x + y; }; document.write(collection(3,7)) As seen, the function expression is defined with a shorter method. The... Continue Reading →

Object Inside Function

JavaScript object properties can also be defined as functions and is a widely used way. var calculate = { collection: function (n1, n2) { return n1 + n2; }, extraction: function (n1, n2) { return n1 - n2; }, pow: function (n1, n2) { return n1 * n2; }, division: function (n1, n2) { return... Continue Reading →

Closures and Recall Functions

They are included in the functions defined in the functions that are sent as parameters for a function or function in a function defined in JavaScript functions. Therefore, they can use the variables (variable scope) and values ​​within the scope of the function they are defined in. This is a very useful feature commonly used... Continue Reading →

Function Expressions

The function definitions starting with "function" are called a function statement. var func = function (a, b) { return a * b; to make it work: var func = function (a, b) { return a * b; } document.write(func(3,4)) output: 12 The functions defined by the function declarations can be called before they are defined,... Continue Reading →

Recursion of the function.

As with most programming languages, JavaScript functions can call themselves. However, in this case, it is also necessary to establish a control mechanism that will finish the job of calling itself in one place. Otherwise, we receive a stack overflow error when the function calls itself too much. example: function write(dat) { if (dat >... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started