Ad
Code
Diff
  • def hello_world(world): return "Hello World baby" if world else 'No World'
    • def hello_world(world):
    • if world:
    • return "Hello World baby"
    • else:
    • return "No World"
    • def hello_world(world): return "Hello World baby" if world else 'No World'
Fundamentals
Strings
Code
Diff
  • reverseStr = s => [...s].reverse().join('')
    • const reverseStr = s => [...s].reverse().join("")
    • console.log(reverseStr("Lorem ipsum dolor sit amet!"))
    • reverseStr = s => [...s].reverse().join('')
Code
Diff
  • helloWorld = t => t ? 'Hello World baby' : 'No World'
    • helloWorld
    • =_=>
    • _?`Hello World baby`:`No World`
    • helloWorld = t => t ? 'Hello World baby' : 'No World'
Code
Diff
  • sum = (a,b) => a+b;
    • function sum(a,b) {
    • return a+b; // wrong returning
    • }
    • sum = (a,b) => a+b;
Code
Diff
  • digitToText = d => ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'][d]
    • const nums = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
    • function digitToText(digit) {
    • return nums[digit]
    • }
    • digitToText = d => ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'][d]