Skip to content

Instantly share code, notes, and snippets.

View joshuaatencia's full-sized avatar
🏠
Working from home

Joshua Ruiz Atencia joshuaatencia

🏠
Working from home
  • Colombia
View GitHub Profile
@joshuaatencia
joshuaatencia / examplebymaximilian.ts
Last active March 25, 2021 19:43
function with diferent varial's type
type Combinable = number | string;
type ConversionDescriptor = 'as-number' | 'as-text';
function combine(input1: Combinable, input2: Combinable, resultConversation: ConversionDescriptor){
let result;
if(typeof input1 === 'number' && typeof input2 === 'number' || resultConversation === 'as-number'){
result = +input1 + +input2;
}else{
result = `${input1} ${input2}`;