Skip to content

推薦其他『自我練習』資源:30 Seconds of Code #1

Description

@liuderchi

看到使用 Codewar 作為自我練習 也想推薦一個資源:

30 seconds of code

它標榜收集了 可以在三十秒內理解的實用 JS code

用起來個人覺得有幾個優點:

個人會在瀏覽器 console 下這段程式碼『隨機閱讀』,像是背英文單字卡一樣跳著看。

snippets = document.querySelectorAll('pre.language-js:nth-child(3)');
topics = document.querySelectorAll('h3.section');
topics[Math.round(Math.random()*topics.length)].scrollIntoView(true);

或是把程式碼當作答案:先遮起來,讀題目想一想,想不到再移動滑鼠看答案

document.querySelectorAll('pre.language-js').forEach(el => {
  if (el.nextSibling.nodeName === 'LABEL') {
    el.style.opacity = 0.03;
    el.onmouseenter = function() { this.style.opacity = 1; }
    el.onmouseleave = function() { this.style.opacity = 0.03; }
}})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions