1. html {<br /> background: linear-gradient(to right, #C9FFBF, #FFAFBD) a special kind of <image> ;<br /> background-size: cover;<br /> font-family: 'helvetica neue';<br /> text-align: center;<br /> font-size: 10px;<br /> }<br /> <br />.hand {<br /> width: 50%;<br /> height: 4px;<br /> background: rgb(100, 100, 100);<br /> position: absolute;<br /> top: 50%;<br /> transform-origin: 100%;<br /> transition: all 0.05s;<br /> transition-timing-function: cubic-bezier(0.07, 2.43, 0.46, 0.76);<br /> }

function setTime() {
let now = new Date();

  1. let second = now.getSeconds();<br /> let secondDeg = (second / 60) * 360 + 90;<br /> secondHand.style.transform = `rotate(${secondDeg}deg)`;
  2. let min = now.getMinutes();<br /> let minDeg = ((min / 60) * 360) + ((second / 60) * 6) + 90;<br /> minHand.style.transform = `rotate(${minDeg}Deg)`;
  3. let hour = now.getHours();<br /> let hourDeg = ((hour / 12) * 360) + ((min / 60) * 30) + 90;<br /> hourHand.style.transform = `rotate(${hourDeg}Deg)`;<br /> console.log(hour)<br /> }

  1. let a = []
  2. console.log(a[0]) //undefined
  1. let a = [1]
  2. a.push([2,3])
  3. console.log(a) // [1, [2, 3]]

image.png

  1. // --- Directions
  2. // Given an array and chunk size, divide the array into many subarrays
  3. // where each subarray is of length size
  4. // --- Examples
  5. // chunk([1, 2, 3, 4], 2) --> [[ 1, 2], [3, 4]]
  6. // chunk([1, 2, 3, 4, 5], 2) --> [[ 1, 2], [3, 4], [5]]
  7. // chunk([1, 2, 3, 4, 5, 6, 7, 8], 3) --> [[ 1, 2, 3], [4, 5, 6], [7, 8]]
  8. // chunk([1, 2, 3, 4, 5], 4) --> [[ 1, 2, 3, 4], [5]]
  9. // chunk([1, 2, 3, 4, 5], 10) --> [[ 1, 2, 3, 4, 5]]

function chunk(array, size) {
const newArr = [];
for (let i of array) {
let last = newArr[newArr.length - 1];
if ( !last || last.length === size) {
newArr.push([i]);
} else {
last.push(i);
}
}
return newArr;
}


  1. // --- Directions
  2. // Check to see if two provided strings are anagrams of eachother.
  3. // One string is an anagram of another if it uses the same characters
  4. // in the same quantity. Only consider characters, not spaces
  5. // or punctuation. Consider capital letters to be the same as lower case
  6. // --- Examples
  7. // anagrams('rail safety', 'fairy tales') --> True
  8. // anagrams('RAIL! SAFETY!', 'fairy tales') --> True
  9. // anagrams('Hi there', 'Bye there') --> False

function anagrams(stringA, stringB) {
const charMapA = buildStrMap(stringA);
const charMapB = buildStrMap(stringB);

if (Object.keys(charMapA).length !== Object.keys(charMapB).length) return false;

for (let i in charMapA) {
if (charMapA[i] !== charMapB[i]) return false;
}

return true;
function buildStrMap(str) {
const strMap = {};
const cleanedStr = str.replace(/[^\w]/g, ‘’).toLowerCase();
for (let i of cleanedStr) {
strMap[i] = strMap[i] + 1 || 1;
}
return strMap;
}
}


swiss design


  1. // --- Directions
  2. // Write a function that accepts a string. The function should
  3. // capitalize the first letter of each word in the string then
  4. // return the capitalized string.
  5. // --- Examples
  6. // capitalize('a short sentence') --> 'A Short Sentence'
  7. // capitalize('a lazy fox') --> 'A Lazy Fox'
  8. // capitalize('look, it is working!') --> 'Look, It Is Working!'

function capitalize(str) {
return str.split(‘ ‘)
.map((subStr) => { // str可以直接这样用!
return subStr[0].toUpperCase() + subStr.slice(1);})
.join(‘ ‘);
}


image.png