Last active
January 28, 2022 04:39
-
-
Save misterpoloy/bf099dc4e7188d8be94eddcd5814dcaf to your computer and use it in GitHub Desktop.
Create a function `generateUrl` to generate a URL from given parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// exercise 2 | |
const payload = { | |
width: 360, | |
height: 300, | |
locale: 'en', | |
toolbar_bg: '', | |
interval: '3h', | |
pair: 'BTC_USD', | |
} | |
let URL = "http://testurl.bitfinx.com/" | |
const getURL = (data) => { | |
const params = Object.keys(data) | |
.filter(param => data[param]) | |
.map(key => `${key}=${data[key]}`) | |
.join('&') | |
return `${URL}?${params}` | |
} | |
console.log(getURL(payload)) | |
// Excersie 3 | |
const volumeSetup = () => { | |
// I'm not sure if this part works at all, I'm assuming is part of the demo | |
const volumeUnit = window.APP.util.getSettings('ticker_vol_unit').toUpperCase(); | |
// Since we're using a patter convention maybe a more adaptble way would be to use the sufix as a identifier | |
// Easier to read and maintain | |
$(`#tickervolccy_${volumeUnit === 'FIRSTCCY' ? 0 : volumeUnit}`).prop("checked", true); | |
// override currencies list | |
var result = window.APP.util.initCurrenciesList() | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var volumeSetup = function () {
// setup volume unit interface
var volumeUnit = window.APP.util.getSettings('ticker_vol_unit').toUpperCase();
var element = null;
if (volumeUnit === 'FIRSTCCY') {
element = $('#tickervolccy_0');
} else if (volumeUnit === 'USD') {
element = $('#tickervolccy_USD');
} else if (volumeUnit === 'BTC') {
element = $('#tickervolccy_BTC');
} else if (volumeUnit === 'ETH') {
element = $('#tickervolccy_ETH');
}
if (element) {
element.prop("checked", true);
}
// override currencies list
var result = window.APP.util.initCurrenciesList()
return result
}