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
// get string as argument | |
function switchCharCode(str) { | |
// split string | |
str = str.split(''); | |
str = str.map(function(char) { | |
let char_code; | |
if (char !== ' ') { | |
// convert each char to Unicode value and add three | |
char_code = char.charCodeAt(0); |
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
function findChoice() { | |
// local var generating random number, then console.log() to check it works | |
var rng = Math.floor(Math.random() * 100); | |
console.log(rng); | |
// function determining action to take depending on range of number generated | |
function choice() { | |
if (rng <= 10) { | |
console.log('Below or equal to 10'); | |
} else if (rng > 10 && 20 >= rng) { | |
console.log('Above 10, up to 20'); |
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
function displayClock() { | |
setInterval(function(){ document.getElementById('clock').innerHTML = new Date().toLocaleTimeString(); }, 1000); | |
}; | |
displayClock(); |