Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

compare strings js

const s1 = 'learn';
const s2 = 'today';

console.log(s1 === 'learn');  // true
console.log(s1 === s2);       // false
Comment

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 :: nodejs mysql transactions 
Javascript :: reset reactive state vue 3 
Javascript :: esql convert blob to json 
Javascript :: download file from api response 
Javascript :: angular reference element 
Javascript :: react native measure 
Javascript :: convert rgb to hex 
Javascript :: nextjs starter 
Javascript :: how to target two id using jquery 
Javascript :: multiple elements with same id jquery 
Javascript :: nodejs cache data 
Javascript :: js object to c# object 
Javascript :: gps nodejs 
Javascript :: js immediately invoked function 
Javascript :: vue radio checked if 
Javascript :: hashnode 
Javascript :: swagger on expres node app 
Javascript :: what is syntactic sugar javascript 
Javascript :: js index to index 
Javascript :: import math javascript 
Javascript :: map function in js 
Javascript :: call,bind and apply in javascript 
Javascript :: vue v-for loop array 
Javascript :: jQuery - AJAX load() Method 
Javascript :: window frames javascript 
Javascript :: linked list algorithm javascript 
Javascript :: chart.js on hover and onclick event 
Javascript :: path object d3.js 
Javascript :: map values in range js 
Javascript :: javascript closures 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =