Back to Lola's Webdev-Fu | Lessons

Exercise 2: The Art of Not Breaking Things

You have 10 seconds to type out this code without errors. If you succeed, you earn 10 points. If you fail, the internet will laugh at you.

Challenge 1: Code Golf

Write a JavaScript function that takes a string and returns the longest word in the string.

const longestWord = (str) => {
                let words = str.split(' ');
                let longest = '';
                for (let i = 0; i < words.length; i++) {
                    if (words[i].length > longest.length) {
                        longest = words[i];
                    }
                }
                return longest;
            }
View Solution

Challenge 2: CSS Grid

Create a CSS grid that can display 5 equal-width columns with a 20px gap between them.

View Solution
prophets