Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

typescript if statement

let colour: string = "Blue";

// 	if (condition){
// 		code inside will run if the condition returns true
//  }

if (colour === "Blue"){
    console.log("Blue");
}
else if (colour === "Green"){
    console.log("Green");
}
else {
    console.log("red");
}

// or you could do this 

// let var_name = condition;
// if (var_name){
// 		code inside will run if the condition returns true
// }

let num: number = 10;
let isNumberEven: boolean = num % 2 == 0; // boolean expression
if (isNumberEven){ 
  	console.log("Yes");
}
else {
	console.log("No");
}
Comment

typescript if statement

const max = 100;
let counter = 0;

if (counter < max) {
    counter++;
}

console.log(counter); // 1
Code language: JavaScript (javascript)
Comment

PREVIOUS NEXT
Code Example
Typescript :: --skip tests generate components - Angular 12 - skip-tests vs spec-false 
Typescript :: give all element in a list starts with string 
Typescript :: git delete commits from remote 
Typescript :: from date and to date validation in angular 8 
Typescript :: check if column exists in dataframe python 
Typescript :: plot multiple plots in r 
Typescript :: angular 12 model class 
Typescript :: flutter swiper page indicator 
Typescript :: typescript filter list of objects based on latest date 
Typescript :: object add property typescript 
Typescript :: learn typescript 
Typescript :: typescript generic function 
Typescript :: typescript convert readonly 
Typescript :: Jquery hide() all elements with certain class except one 
Typescript :: Angular import from local library 
Typescript :: compare two lists and remove duplicates java 
Typescript :: deleting conflicting outputs 
Typescript :: how to add multiple inputs to a dictionary python 
Typescript :: react native paper 
Typescript :: enums in typescript 
Typescript :: where to create assets folder in flutter 
Typescript :: destroy objects when they move below camera unity 
Typescript :: import ts in html 
Typescript :: how to load events from an api in table_calendar flutter flutter 
Typescript :: stacks and its operaaton code 
Typescript :: HHow to append lists elixir 
Typescript :: Include Type TypeScript 
Typescript :: date formats in mongodb 
Typescript :: ncbi datasets command-line tool 
Typescript :: sts is not opening in mac 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =