Can some check my wifi-sketch for my ESP8266 pls?

Hi,
I have written (or copy/paste) my first small sketch for starting and stopping the wifi on my ESP8266.

Is this a good way to do it? What is to be improved? I thought it might be a good thing, because its seemed easier to me for use in the future for other sketches. Same sketch as the wifi below I will write for my mqtt server. So I can copy and paste both into an sketch when I need them.

Thank you!! Kind regards.

#include <ESP8266WiFi.h>

#ifndef STASSID
#define STASSID "ssid"
#define STAPSK  "<Passwort>"
#endif

const char* ssid     = STASSID;
const char* password = STAPSK;

void setup() {
  Serial.begin(115200);
}

void loop() {
  //if (WiFi.status() != WL_CONNECTED) {WiFiSwitch("on");}
  //if (WiFi.status() == WL_CONNECTED) {WiFiSwitch("off");}
}

void WiFiSwitch(String Event) {

  if (Event  == "on") {
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    }
  } else if (Event  == "off") {
    while (WiFi.status() == WL_CONNECTED) {
    WiFi.mode(WIFI_OFF);
    delay(500);
    }
  }
}

I see no problem. You are on the correct track, realizing you need some known good software to test the units. You can also add code to print out some of the other items the ESP8266 will give you such as wifi strength etc.