Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript even/uneven numbers

function getEven(limit = 100, countLimit = true) {
	if (countLimit) {
    	for (let i = 0; i <= limit; i++) {
        	if ((i % 2) === 0) {
            	console.log(`Even: ${i}`)
            }
        }
        return
    }
    
    for (let i = 0; i < limit; i++) {
        if ((i % 2) === 0) {
            console.log(`Even: ${i}`)
        }
    }
}

function getUneven(limit = 100, countLimit = true) {
	if (countLimit) {
    	for (let i = 0; i <= limit; i++) {
        	if ((i % 2) !== 0) {
            	console.log(`Uneven: ${i}`)
            }
        }
        return
    }
    
    for (let i = 0; i < limit; i++) {
        if ((i % 2) !== 0) {
            console.log(`Uneven: ${i}`)
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: find the missing number javascript 
Javascript :: cntl intellisense tailwind 
Javascript :: get max type value in solidity 
Javascript :: jQuery - Set 
Javascript :: suitescript get lineitemcount 
Javascript :: pyautogui javascript 
Javascript :: promise limit time 
Javascript :: js regex find newlines 
Javascript :: Javascript: take every nth Element of Array 
Javascript :: window alert javascript css 
Javascript :: Json to npy file 
Javascript :: phaser random line 
Javascript :: phaser export animation to json 
Javascript :: regular expression a-z and 0-9 
Javascript :: how to process string calculation in gdscript 
Javascript :: object destructuring in javascript 
Javascript :: React "Nothing was returned from render Error" Solution 
Javascript :: mobile angular service 
Javascript :: nodelist example 
Javascript :: javascript replace all with variable 
Javascript :: event listeners 
Javascript :: inertia.js 
Javascript :: google places API details JS 
Javascript :: date pipe 
Javascript :: convert a string to array 
Javascript :: mongoose id validator 
Javascript :: copy folder in nodejs 
Javascript :: return statement in javascript 
Javascript :: scroll position 
Javascript :: audio get current time 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =