DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Spin Your Dreidel! Day 1 of the #25DaysOfServerless Challenge
Jen Looper for Microsoft Azure

Posted on

Spin Your Dreidel! Day 1 of the #25DaysOfServerless Challenge

This article is part of #25DaysOfServerless. New challenges will be published every day from Microsoft Cloud Advocates throughout the month of December. Find out more about how Microsoft Azure enables your Serverless functions.


So, an evil grinch has stolen all the servers in the world, and we have to visit many countries to set things right! You can spin up a serverless function in Visual Studio Code almost as fast as you can win all your big brother's gelt. Now you're in Tel Aviv, Israel, and you find that all the dreidels, and any servers having to do with them, are missing! Your task? Save Hanukkah! Build a serverless function to spin a dreidel for you.

dreidel

This is really easy in Azure. Build your Azure function using Visual Studio Code with the Azure Functions Extension installed. Scaffold the function using the tooling (click the lightning bolt to create a new function) and then click the 'bug' icon to run it. Hint: there are four possible dreidel values you can spin.

Tips

A little bit of JavaScript would do the job in index.js:

module.exports = async function (context) {  
    // Χ  (Nun), Χ’ (Gimmel), Χ” (Hay), and Χ© (Shin)
    var num = Math.floor(Math.random() * 3);
    var values = ['Χ’','Χ”','Χ©','Χ ']
        context.res = {
            body: values[num]
        };

};
Enter fullscreen mode Exit fullscreen mode

If you run the API endpoint that you just created with your function in a browser, you'll see a random value appear. You can publish this as a serverless function and save the family party! Extra latkes for you!

Alt Text

Running a solution

Open the spin-the-dreidel folder in Visual Studio Code and run it locally using the debug tool in VS Code. You'll be able to see the randomly-spun dreidel value in the browser.

Want to submit your solution to this challenge? Build a solution locally and then PR this repo. If your solution doesn't involve code you can record a short video and submit it as a PR to the same repo. Make sure to tell us which challenge the solution is for. We're excited to see what you build! Do you have comments or questions? Add them to the comments area below.


Did you know? Dreidel-spinning rules include:

a) Nun means β€œnisht” or β€œnothing.” The player does nothing.

b) Gimel means β€œgantz” or β€œeverything.” The player gets everything in the pot.

c) Hey means β€œhalb” or β€œhalf.” The player gets half of the pot. (If there is an odd number of pieces in the pot, the player takes half of the total plus one).

d) Shin (outside of Israel) means β€œshtel” or β€œput in.” Peh (in Israel) also means β€œput in.” The player adds a game piece to the pot.

Visit MyJewishLearning for all the rules.


Want to submit your solution to this challenge? Build a solution locally and then submit an issue. If your solution doesn't involve code you can record a short video and submit it as a link in the issue desccription. Make sure to tell us which challenge the solution is for. We're excited to see what you build! Do you have comments or questions? Add them to the comments area below.


Watch for surprises all during December as we celebrate 25 Days of Serverless. Stay tuned here on dev.to as we feature challenges and solutions! Sign up for a free account on Azure to get ready for the challenges!

Top comments (1)

Let's team up together 🀝

We're Hiring

We're hiring for a Senior Full Stack Engineer to join the DEV team. Want the deets? Head here to learn more about who we're looking for.