From 80648c5b07f874f93998d2b7b5e0cb14dd967f35 Mon Sep 17 00:00:00 2001 From: perk bevis <130304440+perk-bevis@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:52:59 +0700 Subject: [PATCH] Create Easy.js --- hackerank/Easy.js | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 hackerank/Easy.js diff --git a/hackerank/Easy.js b/hackerank/Easy.js new file mode 100644 index 0000000..64ee474 --- /dev/null +++ b/hackerank/Easy.js @@ -0,0 +1,64 @@ +const countries = [ + 'Albania', + 'Bolivia', + 'Canada', + 'Denmark', + 'Ethiopia', + 'Finland', + 'Germany', + 'Hungary', + 'Ireland', + 'Japan', + 'Kenya' +] + +const webTechs = [ + 'HTML', + 'CSS', + 'JavaScript', + 'React', + 'Redux', + 'Node', + 'MongoDB' +] + +const arr = [] +console.log(arr) +const number = [1,2,3,4,5,6] +console.log(number) +const lengthOfCountries = countries.length; +const lengthOfwebTechs = webTechs.length; +console.log(lengthOfCountries); +console.log(lengthOfwebTechs); +const first = countries[0]; +const middle = countries[Math.floor(countries.length / 2)]; +const last = countries[countries.length - 1]; +console.log("First:", first); +console.log("Middle:", middle); +console.log("Last:", last); +const secondfirst = webTechs[0] +const secondmiddle = webTechs[Math.floor(webTechs.length/2)] +const secondlast = webTechs[webTechs.length -1]; +console.log("secondfirst:", secondfirst); +console.log("secondmiddle:",secondmiddle); +console.log("secondlast:", secondlast); +const mixedDataTypes = [ + 42, + 'Hello', + true, + null, + { name: 'Alice' }, + [1, 2, 3], + undefined +]; +const mixedDataTypess =mixedDataTypes.length +console.log(mixedDataTypes) +const itCompanies = ['Facebook', 'Google', 'Microsoft', 'Apple', 'IBM', 'Oracle' ,'Amazon'] +console.log(itCompanies) +console.log(itCompanies.length) +const firsts = itCompanies[0]; +const middles = itCompanies[Math.floor(itCompanies.length / 2)]; +const lasts = itCompanies[itCompanies.length - 1]; +console.log("First:", firsts); +console.log("Middle:", middles); +console.log("Last:", lasts);