We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
functionMain(){consttotalCoins=Number(17042.67);const[coins,setCoins]=useState("");const[error,setError]=useState("");consthandleOnChange=(e)=>{if(e.target.value===""){setError("Amount cannot be empty");}elseif(e.target.value<=0.01){setError("Amount cannot be less than $0.01");}elseif(e.target.value>totalCoins){setError("Amount cannot exceed the available balance");}setCoins(e.target.value);};return(<divclassName="layout-column align-items-center mx-auto"><h1>CryptoRankExchange</h1><section><divclassName="card-text layout-column align-items-center mt-12 px-8 flex text-center"><label>Iwanttoexchange$<inputclassName="w-10"data-testid="amount-input"requiredtype="number"placeholder="USD"value={coins}onChange={handleOnChange}/>ofmy$<span>{totalCoins}</span>:</label>{error&&<pdata-testid="error"className="form-hint error-text mt-3 pl-0 ml-0">{error}</p>}{/* The errors can be Amount cannot be empty /be less than $0.01/exceed the available balance */}</div></section><Tablecoins={coins}hasError={error}/></div>);}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
CryptoRank Exchange
You are viewing a single comment's thread. Return to all comments →