Shakespearian Insult Generator

The genesis behind this project came from a lesson I usually use when teaching Shakespearian language to my students. Students are given a worksheet with three columns of words from some of Shakespeare’s works. They are asked to combine one word from each column and to hurl insults at one another (and usually myself) to practice reading with fluency and passion, but also to get accustomed to using words that may feel odd to speak aloud.

I found this project to be really easy to put together. I used three arrays to store the three columns (I did not fill them out completely). Then randomly choose an index of each array using Math.floor(Math.random). The most difficult aspect was generating a prompt in the terminal that took in information and spit out the insult.

For this I found an npm package that works with Node called prompt-sync.

const prompt = require('prompt-sync')({sigint: false}); const name = prompt('What is your name? '); let arr1 = ['bawdy','brazen','churlish','distempered']; let arr2 = ['bunch-backed','clay-brained','dog-hearted','empty-hearted']; let arr3 = ['younker','whipster','waterfly','snipe']; let word1 = arr1[Math.floor(Math.random() * 4)]; let word2 = arr2[Math.floor(Math.random() * 4)]; let word3 = arr3[Math.floor(Math.random() * 4)]; console.log(`${name}, thou art a ${word1} ${word2} ${word3} and I don't care who knows it!`);

I believe it is not running in the Codebyte because it does not have the prompt-sync package installed. I am not sure how I would install that in the Codebyte terminal at this point in my learning.

hi @k-montblanc, welcome onboard to Codecademy’s community! Nice to have you here.

I’m afraid for the time being, Codebyte’s capability have yet to reach that advance level. The best suggestion I think you can go with is the workspace of Codecademy.

Otherwise, you can push it into a public code repo (i.e., Github) and share it with the community so we can assist you after.

Hope my response can help.

Thank you for the reply estforesta. I guess my question goes beyond the Codebyte environment and is more geared to “how” one would include packages in their code. Is it something like using import at the beginning?

Yes correct, importing modules always start with the ‘import’ keyword and follow by the package name and others. You can refer to the following;

import <module_name> from <package_name> ;

Of course, for the full list of syntax on how to import/export things in a convenient way, you’d have to perform some research. Here’s one link for your reference; click here.

1 Like