Intoday's video, we'regonnabetaking a lookatmaking a speedtypinggame, whichis a tonoffuntomakeandalsoincrediblyeducational, sinceitteachesyouconceptssuchasdominantrelation A P I callstimersandsomuchmore.
SotheveryfirstthingwewanttodoisthattimerWecanjustcreate a divwiththeclassoftimerandwe'realsogoingtogiveitanideaoftimersowecanaccessthateasilyinourjavascriptandfornow, we'lljustputinthetextofzerosothatweactuallycanseewhat's goingon.
Next, we'regonnaneed a containerDivAndinsideofthiscontainer, Diviseverythinginthisyellowsectionyoucanseehere.
Sofirstwe'regonnahave a divandthisisgoingtobefor a quotedisplay, andwe'realsogonnawanttogivethatan I D, whichisagaingoingtobequotedisplay.
Andthat's justsowecanaccessthatinthejob a scriptandfornow, let's justgiveitthetextofquotesowecanactuallyseewhat's goingon.
Next, weneed a textarea, whichisgoingtobethiscontentinsideofhere.
Andwewantthishere.
Wedon't reallyneedtoworryabout a name.
Wewannahavethissay, quoteinputastheir i.
D.
Wedon't needcolumnsorrose, andthenwecanput a classwhichisgoingtobequoteinputandwe'lljustput a hyphenamerisourceCSSlike.
Thatjustgivesus a littlebitofspacebetweenourinputandouractualtextherethatweshouldbetyping.
Itlooks a littlebitmorepleasing, andnowwecanmoveontostylingtheinput, whichisgoingtobethemostcomplexstylingforthisentireapplication.
Thefirstthing I wanttodo, theywanttoremovethebackgroundcolorhere.
Sowe'rejustgonnasetthattootransparentand I wanttosetthebordertobetwopixelssolidandissueisgoingtobe a slightlydarkerversionofthebackgroundcolorthatwehavehere.
I justcopiedthisover.
Soifwesave, youcanseethatit's just a slightlydarkercolorofthisyellow.
Thatwayitdoesn't standouttoomuch.
Itkindofjustblendsinwiththebackground, whichisreallywhat I want.
Theveryfirstthingweneedtodoisfigureouthowwe'regonnagetourquotesintoourtextboxhere, andthere's a free a p I thatwecanusecalled a p i dotquotablethat I oweyougotoslashrandomandeverytimeweaccessasyouare, well, we'regonnaget a randomquoteinsideofthiscontentattributes.
So, forexample, here's a quoteforDoitagain.
We'regonnaget a differentquotesowecanjustusethat a p I Soit's copythat, andwe'llcreditconstantvariabletostorethatyou'reoh, soit's a randomquote, a p i euro.
It's goingtobeequaltothatquote a p I andyou'llbuildtogetthisfromthegethelprepolinkedinthedescriptionifyouwant.
Nowthatwehavethatdoneweneedtodoisactuallygetour a p i quote, sowecanjustcreate a functionwhichwecouldjustcallgetrandomquoteandinsideofthisfunctionofwhatwewanttodoiswewanttousethefetch a p I withIfifyou'reunfamiliarwiththis, fetch a P I.
I haveanentirevideocoveringfetch a p I.
SojustmakesureyoucheckthatoutLincoln, thecardsand a descriptiondownbelow.
ButessentiallywejustneedtoputintheURLforour a p i, whichisthiseuro.
Andthenwewanttocallthedotthenpropertybecausethisreturns a promise, andinsidehere, we'regoingtoget a responseobject.
AndtoconvertthattoJason, wejustwanttosayresponsedotJason, thisalsoreturns a promise.
Soweneed a separatetheninsideofhere.
Andthisisourdata.
Sothere's a dataattributesisessentiallywhatweseerighthere.
We'regonnacallthis a renderednewquotebecausewe'reactuallygoingtorenderourquoteinsidethisfunction, andwe'regonnamakesureyoucallthisrightatthebeginninglikethisandnotwhatwewanttodoisgetourelements.
We'regonnacreate a span, andthenwecantakethatspan.
Wecansettheinnertexttobeequaltothatcharacter.
Soessentiallywhatwe'redoinghereiswe'regettingeachindividualcharacterinourstring, creating a spanforitandthensettingthetextofthatspantothatindividualcharacter.
AndifwecomeinhereandjustmakesurethatweclearoutourinnerHTMLbysettingitto a blankstringeverytime, nowwhatwecandoandalsothisneedstobeinhertextofcharacterlikethatdirectionyoujustsettothecharactertext.
I talkedaboutit, butneveractuallydidit.
Now, ifwesaythat, ofcourseeverythingisnotworking, andthisbecauseintertextisobviouslynot a function, I needtosettheinnertextlikethisinsteadofcalling a function.
Andnow, asyoucansee, everythingisworkingoverhere.
Butif I actuallyinspectthiselement, you'llnoticethatwehave a bunchdifferentspans.
Whatweneedtodoisjusteverysinglesecondwewanttoupdateourtimerandwecanusesetintervalforthisbecausethistakes a functionandthenitalsotakes a secondparameter, whichishowoftenyouwanttorunthatfunctioninmilliseconds.
Solet's comeinhereandwe'regonnaget a variablecalledtostarttime.
Andthisisjustgoingtobethedatewhenwestartourtimer.
Soinsideofherewecansetourstarttimetobeequalto a newdate, andthisjustgivesusthecurrenttime, thecurrentdate, andnow, insteadofoursetinterval, wewanttodoisjustwannacall a functioncalledgettimerTimejustlikethatandwe'llcreatethatfunctiondownhere.