Skip to main content

Kana, Zvimwe

Not revised yet

Kana/Zvimwe chii?#

Pane dzimwe nguva dzekuti iwewe unogona kuda kuudza computer kuti itarise uye ishandise chidimbu che code mushure mekunge kana chimwe chinhu chiri chokwadi, ndopanoshanda kana. Kana chinhu ichocho chisiri chokwadi, unenge uchiudza kuudza computer kuti ishandise imwe code isiri muma brackets a kana. Code iyoyo inozoshandiswa inoiswa muma brackets a zvimwe

Kuti ugonzwisisa zvatiri kutaura pano, tichashandisa zvinhu izvi:

zvatichashandisa na Kana/Zvimwe
  1. ma variable
  2. enzaniso
  3. nyora()

Kana usina kunzwisisa kuti ma variables ne enzaniso chii, unokurudzirwa kuverenga ma topic iwayo zvekare, uyezve unogona kubvunza mu group re whatsapp kuti ubatsirike

Mashandisirwo a Kana na Zvimwe#

Unoshanda kuzvitupa#

Wapihwa basa kuzvitupa (National IDs)

Ngatimboti iwewe unoshanda kuzvitupa mu Zimbabwe. Mu Zimbabwe, munhu anobvumidzwa kutora chitupa kana achinge asvitsa makore 16. Ngatomboti iwewe basa rako nderekubvunza makore emunhu auya kuzotora chitupa. Kana munhu akati ane makore 16 zvichienda mberi, uchamuudza kuti aende ku office kunotora chitupa, zvimwe uchamuudza kuti anozodzoka kana aane makore 16.

Iwewe semunhu aakugona kushandisa ShonaScript, ukuda kuita kuti munhu auya kuzotora chitupa audzwe zvekuita ne computer. Saka uchanyora code inoita izvi uchiteedzera masteps ari pazasi apa.

Ronga

Step 1 : Kugadzira ma variables#

Tiri kuda kuzoenzanisa zvinhu 2 izvi:

  1. makore anobvumidzwa kuti munhu atore chitupa mu Zimbabwe
  2. makore emunhu auya kuzotora chitupa

Saka zvawaona kuti tichada kuzoshandisa enzaniso, zvaakureva kuti tikufana kugadzira ma variables 2 aya:

  1. makoreAnobvumidzwa
  • Ndiyo variable yemakore anobvumidzwa kuti munhu atore chitupa (16 years)
  1. makoreEMunhu
  • Ndiyo variable yemakore e munhu auya kuzotora chitupa. Pakutanga apa ngatimboti makore emunhu auya kuzotora chitupa nhasi ane makore 15

Zvatapedza kuronga pa step 1, chinyora code yacho seizvi:

Ita
  1. Pa line 1, nyora kuti
makoreAnobvumidzwa = 16
  1. Pa line 2, nyora kuti
makoreEMunhu = 15

se izvi:

Ma nhamba ariku left ayo ndiwo ma nhamba emaline aunoona mu VS Code

Usanyore se izvi

Usagadzire variable yako uchiti: makoreAnobvumidzwa = 16 years

Izvi hazviite nekuti ukadzokora kunoverenga nezve ma variables, uchaona kuti computer ichatarisa ku right side kwe equal sign (=) yobva yaona kuina 16 years. Zvichaitika ndeizvi:

  1. 16 years haasi muma quotes, saka haasi mashoko.
  2. 16 years haisi nhamba nekuti pane 16 na years
  3. 16 years achaonekwa kunge variable, computer ichakuudza kuti manyorero awaita variable iyoyo haasiriwo

Iwewe wanga ukuda kuenzanisa makore, saka makore i nhamba, zvichireva kuti paunogadzira ma variable ako, unofana kuisa nhamba ku right side kwe equal sign.

Step 2: Kushandisa enzaniso na kana na zvimwe#

Zvekuita
  1. Pa line 4, nyora kuti:
kana makoreEMunhu iridiki pane makoreAnobvumidzwa {
  1. pa line 5, nyora kuti:
nyora("Uchiri mudiki, unozodzoka waane makore 16")
  1. pa line 6, nyora kuti:
} zvimwe {
  1. pa line 7, nyora kuti:
nyora("Enda ku Office kunotora chitupa")
  1. pa line 8, nyora kuti:
}

se izvi:

Hausi watyora shona here apa?
Tsananguro

Kana enzaniso iyo iri chokwadi, tikuda kuti computer ishandise code iri muma curly brackets {} ekutanga. Asi kana enzaniso isiri chokwadi tikuda kuti computer ishandise code iri muma curly bracket echipiri anoteera zvimwe.

Tatyora Shona here?

Computer inonzwisisa kuti makoreEmunhu na makoreAnobvumidzwa ma variables. Saka computer ichaverenga ichiti kana variable inonzi makoreEMunhu iridiki pane variable inonzi makoreAnobvumidzwa

Kana wapedza kunyora code yako, chiona kuti mu terminal munonyorwa kuti chii. Zvekare kuti unoita izvi kana uchida kuti code yako isande

Zvekuita

Mu Application ye ShonaScript

  1. nyora code iri mupicture iri pamusoro apa
  2. baya bhatani re round riri pazasi pe screen

Kana kuti

Mu VS Code

  1. mu index.shona, nyora code iri mu picture
  2. mu terminal nyora kuti node shona.js, wobaya enter
  3. mu terminal zvekare, nyora kuti node index.js, wobaya enter

Ukaita izvi zvakanaka, unofana kuona mu terminal makanyorwa kuti:

Uchiri mudiki unozodzoka waane makore 16

Zvechokwadiwo makoreEMunhu anga ari 15 zvichireva kuti haasi aakukwanisa kutora chitupa.

Zvekuita

Mu Application ye ShonaScript

  1. chinja makoreEMunhu kuti aite 18 se izvi:
makoreEMunhu = 18
  1. baya bhatani re round riri pazasi pe screen

Kana kuti

Mu VS Code

Chiisa makore akawanda kudarika 16

  1. mu index.shona, uchinje makoreEMunhu kuti aite 18 se izvi:
makoreEMunhu = 18
  1. mu terminal nyora kuti node shona.js, wobaya enter
  2. mu terminal zvekare, nyora kuti node index.js, wobaya enter

Ikozvino unofana kuona mu application kana kuti mu terminal makanzi:

Enda ku Office kunotora chitupa