“Switch/Case com intervalo numérico” Respostas de código

Switch JavaScript

//javascript multiple case switch statement
var color = "yellow";
var darkOrLight="";
switch(color) {
    case "yellow":case "pink":case "orange":
        darkOrLight = "Light";
        break;
    case "blue":case "purple":case "brown":
        darkOrLight = "Dark";
        break;
    default:
        darkOrLight = "Unknown";
}

//darkOrLight="Light"
Grepper

trocar

-- PUT THIS IN A LOCAL SCRIPT
local UIS = game:GetService("UserInputService")
local switch = false

UIS.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.F then -- replace "F" with key of your choice
			
			if switch == true then
				
                -- put what ever you want to happen when OFF
				print("Its off!")
				switch = false -- must keep this for it to work
			else
            
				-- put what ever you want to happen when ON
				print("Its on!")
				switch = true -- this also has to be here for it to work
			end
		end
	end
end)
Mohammed Hedia

Respostas semelhantes a “Switch/Case com intervalo numérico”

Perguntas semelhantes a “Switch/Case com intervalo numérico”

Mais respostas relacionadas para “Switch/Case com intervalo numérico” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código