Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

Learn JS METHOD CHAINING in 5 minutes! ⛓

40.1K views on YouTube

#javascript #tutorial #course

// Method Chaining = Calling one method after another
// in one continuous line of code.

let username = window.prompt(“Enter your username: “);

// —– NO METHOD CHAINING —–
/*
username = username.trim();
let letter = username.charAt(0);
letter = letter.toUpperCase();

let extraChars = username.slice(1);
extraChars = extraChars.toLowerCase();
username = letter + extraChars;

console.log(username);
*/

// —– METHOD CHAINING —–

username = username.trim().charAt(0).toUpperCase() + username.trim().slice(1).toLowerCase();

console.log(username);