Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to make a random if else in js

if ((Math.random() * 10) + 1 > 5) {
    img.src = '1.jpg';
} else {
    img.src = '2.jpg';
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: getDataSnapshotFirebase 
Javascript :: how to play audio in javascript 
Javascript :: deduplicate array javascript 
Javascript :: this element in javascript 
Javascript :: parsley js decimal 
Javascript :: react native paper modal background 
Javascript :: mongoose delete 
Javascript :: reactjs node sass incompatible with ^4.0.0 ^5.0.0 
Javascript :: how to design an api node js 
Javascript :: how to convert jsonobject to string in java 
Javascript :: reset form input react 
Javascript :: javascript return object property from array 
Javascript :: exporting a class 
Javascript :: getfullyear javascript 
Javascript :: npm run start vs npm start 
Javascript :: html escape function javascript 
Javascript :: lpad javascript 
Javascript :: disable button js 
Javascript :: how to change mui ripple color 
Javascript :: How to send form data from react to express 
Javascript :: Redirect to any page after 5 seconds in Javascript 
Javascript :: format javascript date 
Javascript :: start pm2 node process with flags 
Javascript :: else if javascript 
Javascript :: javascript parse date dd/mm/yyyy hh:mm:ss 
Javascript :: console.log json shopify 
Javascript :: new line in javascript alert 
Javascript :: anagram program in javascript 
Javascript :: dropzone csrf codeigniter 
Javascript :: how check if a form date is before today javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =