Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 49
» Latest member: antwantillman
» Forum threads: 4,492
» Forum posts: 4,495

Full Statistics

Online Users
There are currently 1053 online users.
» 0 Member(s) | 1051 Guest(s)
Yandex, Bing

Latest Threads
SELECT statement with MS ...
Forum: MS Access SQL Tutorials
Last Post: Qomplainerz
07-27-2023, 03:35 PM
» Replies: 0
» Views: 1,080
SELECT statement with the...
Forum: MS Access SQL Tutorials
Last Post: Qomplainerz
07-27-2023, 03:31 PM
» Replies: 0
» Views: 529
Creating hyperlinks in HT...
Forum: HTML5 Tutorials
Last Post: Qomplainerz
07-27-2023, 01:23 PM
» Replies: 0
» Views: 829
What's new in HTML5?
Forum: HTML5 Tutorials
Last Post: Qomplainerz
07-27-2023, 12:48 PM
» Replies: 0
» Views: 555
What is HTML5?
Forum: HTML5 Tutorials
Last Post: Qomplainerz
07-27-2023, 12:43 PM
» Replies: 0
» Views: 520
Neck isometric exercises
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:44 AM
» Replies: 0
» Views: 812
Shoulder shrug
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:43 AM
» Replies: 0
» Views: 476
Neck retraction
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:43 AM
» Replies: 0
» Views: 438
Neck flexion and extensio...
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:42 AM
» Replies: 0
» Views: 506
Neck rotation
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:42 AM
» Replies: 0
» Views: 478

 
  Find the min, max and avg of two numbers in JavaScript
Posted by: Qomplainerz - 04-04-2023, 07:38 AM - Forum: JavaScript Tutorials - No Replies

Code:
num1 = 10;
num2 = 20;
const min = (num1 < num2) ? num1 : num2;
const avg = (num1 + num2) / 2;
const max = (num1 > num2) ? num1 : num2;
document.write("Min = ", min);
document.write("<br>");
document.write("Avg = ", avg);
document.write("<br>");
document.write("Max = ", max);

Print this item

  Add elements at the beginning of an array in JavaScript
Posted by: Qomplainerz - 04-04-2023, 07:37 AM - Forum: JavaScript Tutorials - No Replies

Code:
var numbers = [1, 2, 3, 4, 5];
var num1 = -1;
var num2 = 0;

numbers.unshift(num1, num2);

document.write(numbers);

Print this item

  Add elements at the end of an array in JavaScript
Posted by: Qomplainerz - 04-04-2023, 07:37 AM - Forum: JavaScript Tutorials - No Replies

Code:
var numbers = [1, 2, 3, 4, 5];
var num1 = -1;
var num2 = 0;

numbers.push(num1, num2);

document.write(numbers);

Print this item

  Select elements by name in JavaScript
Posted by: Qomplainerz - 04-04-2023, 07:36 AM - Forum: JavaScript Tutorials - No Replies

The HTML part between the <body></body> tags looks like this:

Code:
<!-- Select elements by name -->

<input type="radio" name="size" value="S"> S
<input type="radio" name="size" value="M"> M
<input type="radio" name="size" value="L"> L
<input type="radio" name="size" value="XL"> XL
<input type="radio" name="size" value="XXL"> XXL

The JavaScript part looks like this:

// Select elements by name

let elems = document.getElementsByName('size');
let sizes = [].map.call(elems, elem => elem.value);

document.write("<br>");
document.write(sizes);
document.write("<br>");

Print this item

  Select elements by tag name in JavaScript
Posted by: Qomplainerz - 04-04-2023, 07:35 AM - Forum: JavaScript Tutorials - No Replies

The HTML part between the <body></body> tags looks like this:

Code:
<!-- Get elements by tag name -->

<div id="container">
  <a href="https://nodejs.org/">Node.js</a>
  <a href="https://openjsf.org/">OpenJS Foundation</a>
  <a href="https://github.com/tc39">Ecma TC39</a>
</div>

The JavaScript part looks like this:

Code:
let links = document.getElementsByTagName('a');

document.write("<br>");
document.write('Link count: ', links.length);
document.write("<br>");

// Show the href of links

for(let i = 0; i < links.length; i++)
  {
    document.write(links[i].href);
  }

Print this item

  Select elements by class name in JavaScript
Posted by: Qomplainerz - 04-04-2023, 07:33 AM - Forum: JavaScript Tutorials - No Replies

The HTML part between the <body></body> tags looks like this:

Code:
<!-- Select elements by class name -->

<div id="container">
  <p class="note">The first note.</p>
  <p class="note">The second note.</p>
  <p class="note">The third note.</p>
</div>

The JavaScript part looks like this:

Code:
// Select elements by class name

let elements = document.getElementsByClassName('note');

for(let i = 0; i < elements.length; i++)
  {
    document.write(elements[i].innerHTML);
  }

Print this item

  Select elements by ID in JavaScript
Posted by: Qomplainerz - 04-04-2023, 07:23 AM - Forum: JavaScript Tutorials - No Replies

The HTML part between the <body></body> tags looks like this:

Code:
<!-- Select elements by ID -->

<h1 id="message">JavaScript getElementById() Demo</h1>

The JavaScript part looks like this:

Code:
// Select elements by ID

document.getElementById("message").innerHTML = "Demo";

Print this item

  Select elements by CSS selector in JavaScript
Posted by: Qomplainerz - 04-04-2023, 07:18 AM - Forum: JavaScript Tutorials - No Replies

The HTML part between the <body></body> tags looks like this:

Code:
<!-- Selecting elements by CSS selector -->

<div id="container">
  <p class="note">This is a note</p>
  <p class="note">This is another note</p>
  <p class="error">An error message</p>
</div>

The JavaScript part of the code looks like this:

Code:
// Selecting elements by CSS selector

let container = document.querySelector("#container");

document.write(container);

Print this item

  Check if an array contains a string in JavaScript
Posted by: Qomplainerz - 04-04-2023, 07:14 AM - Forum: JavaScript Tutorials - No Replies

// Check if an array contains a string

const colors = ['red', 'green', 'blue'];
const result = colors.includes('red');

document.write(result);

Print this item

  Check if an array contains a string, ignoring upper- or lowercase in JavaScript
Posted by: Qomplainerz - 04-04-2023, 07:13 AM - Forum: JavaScript Tutorials - No Replies

// Check if an array contains a string ignoring upper- or lowercase in JavaScript

const colors = ['Red', 'GREEN', 'Blue'];
const result = colors.map(e => e.toLocaleLowerCase())
.includes('green');

document.write(result);

Print this item