Created
May 14, 2021 19:58
-
-
Save craigderington/378f19cb00b0237275397be71bff67d0 to your computer and use it in GitHub Desktop.
Coding Interview
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
// coding: utf-8 | |
// example 1 | |
// string length | |
// given the following string, 'this example string', write the string length to the console | |
var string = 'this example string'; | |
console.log(string.length); | |
// example 2 - arrays | |
// write a function to 'sum' the values in array | |
// times and print the variable totals to the console | |
// you can use a for-loop or for-each loop | |
times = [3.25, 4.75, 2.50, 3.00, 1.00, 0.50, 1.50] | |
var sum = 0; | |
for(int i=0; i<times.length;i++) { | |
sum += times[i]; | |
console.log('Sum is: ' + sum); | |
} | |
// example 3 | |
// for-loop | |
// loop total and sum to limit | |
var total = 0; | |
var limit = 10; | |
for(int i=total; i<limit; i++) { | |
total += i; | |
} | |
console.log('Total is: ' +total); | |
// example 4 - for-each array | |
// write a for-each function to add the trading pairs to list symbols | |
// and write the value for symbols to the console | |
pairs = ["btcusd","ethusd","ltcusd","adabtc","xlmusd","doge"] | |
symbols = []; | |
pairs.forEach(function(obj) { | |
symbols.push(obj); | |
}) | |
console.log('Symbols array: ' + symbols.toString()); | |
// example 5 - json list | |
// write a function to write the 'key' value to the console | |
var keypairs = [{ | |
"key": "adMidServer", | |
"value": "ChampioneBridge", | |
"correlation_id": "51e57d4cd7e9a3d3e37c1790c1c7b6d2e25d0e091af12e88a19cd00c64bf5b51" | |
}, | |
{ | |
"key": "adServer", | |
"value": "STACD001", | |
"correlation_id": "d1b55ee2d83fcd4d5a77a608869f1247d5ba7c0d81cc74d44081161044dddbe5" | |
}, | |
{ | |
"key": "MailServer", | |
"value": "smtp.systemic.us", | |
"correlation_id": "cf07f38a39e8eb602b182e1162777f7f486091c38b5eab5019babf6f66c1f191" | |
}]; | |
for(var i=0; i<keypairs.length;i++){ | |
console.log(keypairs[i].key); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment