What is Greetr? Greetr is a small JavaScript library that Walker Christian Forrester wrote. Given a first name, a last name and an optional language, it builds a formal or an informal greeting. Its list of supported languages has 21 entries, from English and Spanish to Hausa, Swahili and Indonesian.
How it works
Greetr is built like a miniature jQuery. You call G$('first', 'last') without the new keyword, set the language with setLang, and chain the next call on with a dot. The language list and the greetings sit privately inside a closure, the shared methods live once on the prototype, and a language that isn't supported stops with an "Invalid language" error. It can write the greeting into a web page with jQuery or with plain JavaScript.
Building a library like Greetr is a well-known exercise from Anthony Alicea's course JavaScript: Understanding the Weird Parts. Walker's version goes past the basics with its 21 languages. The code is public on GitHub at walkforr/greeterLibrary, and there is a live demo at walkforr.github.io/greeterLibrary.
Related
// elsewhere
Find Walker online
- GitHubgithub.com/walkforr
- LinkedInin/walker-forrester-011735166
- LinkedInin/walker-forrester-73323b9b
- Facebookfacebook.com · Page
- Substackwalkerforrester.substack.com
- WordPresswalkerforrester.wordpress.com
- Mediummedium.com/@walkerforresterfamily
- Tumblrwalkerforrester.tumblr.com
- Pinterestpinterest.com/walkerforresterfamily
- Linktreelinktr.ee/walkerforrester
- Gravatargravatar.com/walkerforresterfamily
- About.meabout.me/walkerforrester
- Blueskywalkerforrester.bsky.social
- DEVdev.to/walkerforresterfamily
- Hashnodewalkerforrester.hashnode.dev
- Bloggerwalkerforrester.blogspot.com