codingtcher.com
Theme Night
Home
Login

Javascript

Home » Javascript

JavaScript

//The unshift() method adds a new element to an array (at the beginning), and "unshifts" older elements:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.unshift("Lemon");
//The unshift() method returns the new array length : >> 5


/*if you find this answer is useful ,
upvote ⇑⇑ , so  the others can benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)*/

javascript

let str = "12345.00";
str = str.substring(0, str.length - 1);

javascript

#include<stdio.h>

int main()
{
    int count,n;

    printf("Enter the value of N: ");
    scanf("%d",&n);

    count=1;

start:
    printf("num: %4d, Square: %4d, Cube: %4d\n",count,(count*count),(count*count*count));
    count++;

    if(count<=n)
        goto start;

    return 0;
}

JavaScript

function square(arr) {
       const newArr = arr.map(x => x * x );
    return newArr ;
  
  //if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)

javascript

//The sort() method sorts an array alphabetically:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort();
//output >> [ "Apple",Banana","Mango", "Orange" ]

//if you find the answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)

javascript

/**
* Delay for a number of milliseconds
*/
function sleep(delay) {
    var start = new Date().getTime();
    while (new Date().getTime() < start + delay);
}

javascript

dequeue() {
    const item = this.elements[this.head];
    delete this.elements[this.head];
    this.head++;
    return item;
  }

Javascript Related Post