function getValue(options) {
    return new Promise((resolve, reject) => {
        let url = apiURL;

        // Set default value of `currencyCode` and `isDecimal`
        options = Object.assign({
            currencyCode: 'USD',
            isDecimal: false
        }, options);

        const {currencyCode} = options;
        
        // Check that the type of `currencyCode` is `string`
        if (typeof currencyCode !== 'string') {
            throw new TypeError('`currencyCode` should be of type `string`');
        }

        // Check if the current currency code mathches any valid ones
        let found = false;
        for (let i = 0; i < currencies.length; i++) {
            if (currencyCode.toUpperCase() === currencies[i].code) {
                found = true;
                break;
            }
        }

        if (!found) {
            reject(new Error('Please choose a valid `currencyCode`'));
            return;
        }

        if (currencyCode !== 'USD') {
            url += '?convert=' + currencyCode;
        }

        sendHttpRequest(url).then(response => {
            // Set the `currencyValue` to the `USD` value by default
            let currencyValue = (currencyCode === 'USD') ? response.price_usd : response['price_' + currencyCode.toLowerCase()];

            if (!currencyValue) {
                reject(new Error('Failed to retrieve Bitcoin value'));
                return;
            }
            
            currencyValue = Number(currencyValue);
            currencyValue = parseOptions(currencyValue, options);
            resolve(currencyValue);
            return;
        }).catch(error => reject(error));
    });
}
function getValue(options) {
    return new Promise((resolve, reject) => {
        let url = apiURL;

        
        options = Object.assign({
            currencyCode: 'USD',
            isDecimal: false
        }, options);

        const {currencyCode} = options;
        
        
        if (typeof currencyCode !== 'string') {
            throw new TypeError('`currencyCode` should be of type `string`');
        }

        
        let found = false;
        for (let i = 0; i < currencies.length; i++) {
            if (currencyCode.toUpperCase() === currencies[i].code) {
                found = true;
                break;
            }
        }

        if (!found) {
            reject(new Error('Please choose a valid `currencyCode`'));
            return;
        }

        if (currencyCode !== 'USD') {
            url += '?convert=' + currencyCode;
        }

        sendHttpRequest(url).then(response => {
            
            let currencyValue = (currencyCode === 'USD') ? response.price_usd : response['price_' + currencyCode.toLowerCase()];

            if (!currencyValue) {
                reject(new Error('Failed to retrieve Bitcoin value'));
                return;
            }
            
            currencyValue = Number(currencyValue);
            currencyValue = parseOptions(currencyValue, options);
            resolve(currencyValue);
            return;
        }).catch(error => reject(error));
    });
}
function getValue ( options ) { return new Promise ( ( resolve , reject ) => { let url = apiURL ; // Set default value of `currencyCode` and `isDecimal` options = Object . assign ( { currencyCode : 'USD' , isDecimal : false } , options ) ; const { currencyCode } = options ; // Check that the type of `currencyCode` is `string` if ( typeof currencyCode !== 'string' ) { throw new TypeError ( '`currencyCode` should be of type `string`' ) ; } // Check if the current currency code mathches any valid ones let found = false ; for ( let i = 0 ; i < currencies . length ; i ++ ) { if ( currencyCode . toUpperCase ( ) === currencies [ i ] . code ) { found = true ; break ; } } if ( ! found ) { reject ( new Error ( 'Please choose a valid `currencyCode`' ) ) ; return ; } if ( currencyCode !== 'USD' ) { url += '?convert=' + currencyCode ; } sendHttpRequest ( url ) . then ( response => { // Set the `currencyValue` to the `USD` value by default let currencyValue = ( currencyCode === 'USD' ) ? response . price_usd : response [ 'price_' + currencyCode . toLowerCase ( ) ] ; if ( ! currencyValue ) { reject ( new Error ( 'Failed to retrieve Bitcoin value' ) ) ; return ; } currencyValue = Number ( currencyValue ) ; currencyValue = parseOptions ( currencyValue , options ) ; resolve ( currencyValue ) ; return ; } ) . catch ( error => reject ( error ) ) ; } ) ; }
input1 can both be boolean (isDecimal) and number (quantity), but not the same type input2 can be boolean (isDecimal) if input1 is number (quantity) TODO: new text here
input1 can both be boolean ( isDecimal ) and number ( quantity ) but not the same type input2 can be boolean ( isDecimal ) if input1 is number ( quantity ) TODO : new text here