---
title: "Discussion on \"Setting Variables Using Switch Statements In JavaScript\" | Hashnode"
description: "Discussion on \"Setting Variables Using Switch Statements In JavaScript\". Here is a snippet showing an example of how this would be done. Each animal has a favorite color which we will determine using a switch statement.\nconst animal = \"dog\";\n\nconst color = (()=>{\n    switch (animal) {\n        case \"cat\":\n            retur..."
url: "https://hashnode.com/posts/setting-variables-using-switch-statements-in-javascript/60070bdf094f2b30301ddc95"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Setting Variables Using Switch Statements In JavaScript](https://blog.kyleschwartz.ca/setting-variables-using-switch-statements-in-javascript?utm_source=hashnode&utm_medium=feed)

Here is a snippet showing an example of how this would be done. Each animal has a favorite color which we will determine using a switch statement. const animal = "dog"; const color = (()=>{ switch (animal) { case "cat": retur...

Jan 19, 2021 · 2 min read · blog.kyleschwartz.ca  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#tricks](https://hashnode.com/tag/tricks)

## Written by

[Kyle Schwartz](https://hashnode.com/@ksmarty)

@ksmarty · Toronto, Canada

  
[View profile](https://hashnode.com/@ksmarty)

Co-Op Student @sanofipasteur

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
