Coder Social home page Coder Social logo

js-for-react-native-11029640's Introduction

JavaScript Array Manipulation and User Profiles

Student ID: 11029640

Task 1: Array Manipulation

  • File: arrayManipulation.js
  • Function: processArray
    • Description: Takes an array of numbers as an argument and returns a new array where each even number is squared and each odd number is tripled.

Task 2: String Formatting Based on Numbers

  • File: arrayManipulation.js
  • Function: formatArrayStrings
    • Description: Takes two arrays as arguments: an array of strings and an array of numbers processed by processArray. It modifies each string based on its corresponding number: capitalizes the entire string if the number is even, and converts the string to lowercase if the number is odd.

Task 3: User Profile Creation

  • File: userInfo.js
  • Function: createUserProfiles
    • Description: Takes an array of names and the array of modified names from Task 2. Returns an array of objects, each containing originalName, modifiedName, and id (auto-incremented starting from 1).

Usage

  1. arrayManipulation.js
    • Contains the functions processArray and formatArrayStrings.
    • These functions can be imported and used in other files.
  2. userInfo.js
    • Contains the function createUserProfiles.
    • This function can be imported and used in other files.

Example

const { processArray, formatArrayStrings } = require('./arrayManipulation');
const { createUserProfiles } = require('./userInfo');

const numbers = [1, 2, 3, 4];
const processedNumbers = processArray(numbers); // [3, 4, 9, 16]

const strings = ["apple", "banana", "cherry", "date"];
const formattedStrings = formatArrayStrings(strings, processedNumbers); // ["apple", "BANANA", "cherry", "DATE"]

const userProfiles = createUserProfiles(strings, formattedStrings);
console.log(userProfiles);
/*
[
  { id: 1, originalName: 'apple', modifiedName: 'apple' },
  { id: 2, originalName: 'banana', modifiedName: 'BANANA' },
  { id: 3, originalName: 'cherry', modifiedName: 'cherry' },
  { id: 4, originalName: 'date', modifiedName: 'DATE' }
]
*/

js-for-react-native-11029640's People

Contributors

owusu-desmond avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.