Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

string comparison javascript

string1.localeCompare(string2);
//returns postivie number if string1>string2
//returns negative number if string1<string2
//returns 0 if they are equivalent
Comment

javascript string compare

employees.sort((a, b) => {
    let fa = a.firstName.toLowerCase(),
        fb = b.firstName.toLowerCase();

    if (fa < fb) {
        return -1;
    }
    if (fa > fb) {
        return 1;
    }
    return 0;
});
Code language: JavaScript (javascript)
Comment

Javascript comparison

const num1 = 450;
const num2 = 350;
const num3 = 1000;

if (num1 > num2 && num1 > num3) {
    console.log("num1 is bigger then num2 and num3");
} else if (num2 > num1 && num2 > num3) {
    console.log("num2 is bigger num1 and num3");
} else {
    console.log("num3 is bigger then num1 and num2");
}
//Output: num3 is bigger then num1 and num2
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery form validation 
Javascript :: what is getter and setter in javascript 
Javascript :: search object array javascript 
Javascript :: add font awesome with nextjs 
Javascript :: networkx get nodes 
Javascript :: 100 day javascript challenge 
Javascript :: alternative to setinterval 
Javascript :: nuxt auth user info 
Javascript :: lodash filter array objects 
Javascript :: sequelize manual model/index.js 
Javascript :: javascript foreach in object 
Javascript :: create a customer in stripe node.js 
Javascript :: query parameters 
Javascript :: how to convert react component to image 
Javascript :: smooth scroll react 
Javascript :: javascript select audio device 
Javascript :: cm to inches 
Javascript :: how to check provided value is in array in javascript 
Javascript :: create multiple array buttons in javascript 
Javascript :: javascript Create a RegEx 
Javascript :: usenavigate and uselocation in react 
Javascript :: jq ridirect 
Javascript :: sumar un mes a una fecha javascript moment 
Javascript :: javascript alert html 
Javascript :: react snack bar 
Javascript :: rivets js bind 
Javascript :: Replacing String Content 
Javascript :: npm install say unmet dependencies 
Javascript :: Expresion regular para validar correo electrónico 
Javascript :: this.jsObject.functions is not a function 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =